Comment

minhducit

In your code f.read().split('\n') will return one more line comparing with the f.readlines().
However the last line is ""

So they are not equal :)