Your file handle contains a position pointer. You can find out where you're at using fh.tell. It will move through the file for each line. Once you reach the end of the line, if you want to iterate through it again, you need to reset this pointer. fh.seek(0) would accomplish that for you.