def render(line, prefix_arg=None, color=-1):
    """
    Turn a line of text into a ready-to-display string.
    If prefix_arg is set, prepend it to the line.
    If color is set, change to that color at the beginning of the rendered line and change out before the newline (if
    there is a newline).
    :param str line: Output line to be rendered
    :param str prefix_arg: Optional prefix to be stuck at the beginning of the rendered line
    :param int color: If 0-255, insert escape codes to display the line in that color
    """
    pretext = '' if prefix_arg is None else prefix_arg
    if -1 < color < 256:
        pretext = "\x1b[38;5;{}m{}".format(str(color), pretext)
        if line[-1] == "\n":
            line = "{}\x1b[0m\n".format(line[:-1])
        else:
            line = "{}\x1b[0m".format(line)
    return "{}{}".format(pretext, line)