<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def keep_on_one_line():
 """ Keep all the output generated within a with-block on one line. Whenever a new line would be printed, instead reset the cursor to the beginning of the line and print the new line without a line break. """


    class CondensedStream:

        def __init__(self):
            self.sys_stdout = sys.stdout

        def write(self, string):
            with swap_streams(self.sys_stdout):
                string = string.replace('\n', ' ')
                string = truncate_to_fit_terminal(string)
                if string.strip():
                    update(string)

        def flush(self):
            with swap_streams(self.sys_stdout):
                flush()


    with swap_streams(CondensedStream()):
        yield