def normalize_line(line, newline):
    """Return line with fixed ending, if ending was present in line.

    Otherwise, does nothing.
    """
    stripped = line.rstrip('\n\r')
    if stripped != line:
        return stripped + newline
    return line
