<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_error_marker(text, position, start_line=1):
 """Add a caret marking a given position in a string of input. Returns (new_text, caret_line). """

    indent = "    "
    lines = []
    caret_line = start_line
    for line in text.split("\n"):
        lines.append(indent + line)

        if 0 <= position <= len(line):
            lines.append(indent + (" " * position) + "^")
            caret_line = start_line

        position -= len(line)
        position -= 1  # for the newline
        start_line += 1

    return "\n".join(lines), caret_line