I just came across this piece of code
while 1: line = data.readline() if not line: break #...
and thought, there must
Try this one, works for files opened with open('filename')
open('filename')
for line in iter(data.readline, b''):