def splitlines(s):
    """splits the string into a list of lines, retaining the newline character.
    s.split("\n") cannot be used because it removes the newline character."""
    assert isinstance(s, str)
    l = []
    b = 0
    for i,c in enumerate(s):
        if c == '\n':
            l.append(s[b:(i+1)])
            b = i+1
    if b != len(s):
        l.append(s[b:])
    return l