def enforceOneLineEnding(s):
    """Ensures that a string contains exactly 1 line ending character at the end."""
    if len(s) == 0:
        return "\n"
    if s[-1] == "\n":
        return s
    return s + "\n"