def write(p_file, p_string):
    """
    Write p_string to file p_file, trailed by a newline character.

    ANSI codes are removed when the file is not a TTY (and colors are
    automatically determined).
    """
    if not config().colors(p_file.isatty()):
        p_string = escape_ansi(p_string)

    if p_string:
        p_file.write(p_string + "\n")
Write p_string to file p_file, trailed by a newline character.

    ANSI codes are removed when the file is not a TTY (and colors are
    automatically determined).