<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, data):
        ''' This could be a bit less clumsy. '''
        if data == '\n':  # print does this
            return self.stream.write(data)
        else:
            bytes_ = 0
            for line in data.splitlines(True):
                nl = ''
                if line.endswith('\n'):  # mv nl to end:
                    line = line[:-1]
                    nl = '\n'
                bytes_ += self.stream.write(
                                f'{self.start}{line}{self.default}{nl}'
                          ) or 0  # in case None returned (on Windows)
            return bytes_