def remove_excessive_new_lines(string):
    """Change string so there are at most four line breaks."""
    newlines = 0
    index = string.find('\n')

    while index != -1:
        newlines += 1
        if newlines >= 4:
            # snip string after the fourth new line
            return string[:index]
        index = string.find('\n', index + 1)

    # not too many new lines, return string unchanged
    return string