def locate_first_newline(stream, start): """We need to locate the first newline""" stream.seek(start) for line in stream: if is_empty(line): return stream.tell()