<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(self, string, *args, **kwargs):
 """Writes a string into the source code, applying indentation if required """

        if self.on_new_line:
            self.on_new_line = False  # We're not on a new line anymore
            # If the string was not empty, indent; Else probably a new line
            if string.strip():
                self.indent()

        if args or kwargs:
            self.out_stream.write(string.format(*args, **kwargs))
        else:
            self.out_stream.write(string)