def line_at_index(string, index):
    """ Returns the line at the given index of the given string.
    """
    if index < 0:
        index =  index % len(string)
    start = string.rfind('\n', 0, index)+1
    end = string.find('\n', index)
    suffix = '\\n' if end >= 0 else '\\0'
    if end < 0:
        end = len(string)
    return f"{string[start:end]}{suffix}"