def next_nl_or_end(s, n=0):
    """Next newline or end of text"""
    # first identify starting newlines, we pass them
    start = n
    while start < len(s) - 1 and s[start] == '\n':
        start += 1
    p = s.find('\n', start + 1)
    if p > -1:
        # Another newline found, continue until no more newlines or end of string
        while p < len(s) and s[p] == '\n':
            p += 1
        return p
    else:
        # No (more) newlines found, return length of string as end index
        return len(s)