def format_output(tosave, formatter):
    """
    Applies the formatting function, formatter, on tosave.
    If the resulting string does not have a newline adds it.
    Otherwise returns the formatted string
    :param tosave: The item to be string serialized
    :param formatter: The formatter function applied to item
    :return: The formatted string after formatter has been applied to tosave
    """
    formatted = formatter(tosave)
    if not formatted.endswith('\n'):
        formatted = formatted + '\n'
    return formatted