def METHOD_NAME(stream, delim='\n'):
    'Generates one line/row/record at a time from stream, separated by delim'
    buf = type(delim)()
    for chunk in stream:
        buf += chunk
        *rows, buf = buf.split(delim)
        yield from rows
    buf = buf.rstrip(delim)  # trim empty trailing lines
    if buf:
        yield from buf.rstrip(delim).split(delim)