If you don't want to read in the file, then you can use
or in your original code above. You'll need an if statement to catch when either of the two $lineX values is undefined, and make the comparison otherwise. The code can increase in complexity as you decide whether you want to see if things are offset in a file, rather than if the same lines have the same values.