def fileLineIter(inputFile, inputNewline='\n', outputNewline=None, readSize
    =8192):
    'Like the normal file iter but you can set what string indicates newline.\n   The newline string can be arbitrarily long; it need not be restricted to a\n   single character. You can also set the read size and control whether or not\n   the newline string is left on the end of the iterated lines.  Setting\n   newline to \'\x00\' is particularly good for use with an input file created with\n   something like "os.popen(\'find -print0\')".\n   '
if outputNewline is None:
    outputNewline = inputNewline
partialLine = ''
while True:
    charsJustRead = inputFile.read(readSize)
if not charsJustRead:
    break
partialLine += charsJustRead
lines = partialLine.split(inputNewline)
partialLine = lines.pop()
for line in lines:
    yield line + outputNewline
if partialLine:
    yield partialLine
Python - how to read file with NUL delimited lines?