<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _indent(stream, indent, *msgs):
 """ write a message to a text stream, with indentation. Also ensures that the output encoding of the messages is safe for writing. """


    for x in range(0, indent):
        stream.write("  ")
    for x in msgs:
        # Any nicer way? In Py2 x can be 'str' or 'unicode'.
        stream.write(x.encode("ascii", "backslashreplace").decode("ascii"))
    stream.write("\n")