def _process_line(line):
    """Escape string literals and strip newline characters."""
    if not isinstance(line, str):
        raise TypeError("Routine lines should be strings.")

    if line.endswith('\n'):
        line = line[:-1]

    return line