def lazyread(f, delimiter):
<EOL>try:<EOL><INDENT>running = f.read(<NUM_LIT:0>)<EOL><DEDENT>except Exception as e:<EOL><INDENT>if e.__class__.__name__ == '<STR_LIT>':<EOL><INDENT>running = b'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>while True:<EOL><INDENT>new_data = f.read(<NUM_LIT>)<EOL>if not new_data:<EOL><INDENT>yield running<EOL>return<EOL><DEDENT>running += new_data<EOL>while delimiter in running:<EOL><INDENT>curr, running = running.split(delimiter, <NUM_LIT:1>)<EOL>yield curr + delimiter<EOL><DEDENT><DEDENT>
Generator which continually reads ``f`` to the next instance
of ``delimiter``.

This allows you to do batch processing on the contents of ``f`` without
loading the entire file into memory.

:param f: Any file-like object which has a ``.read()`` method.
:param delimiter: Delimiter on which to split up the file.