<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_text(self, data, encoding=None, errors=None):
 """ Open the file in text mode, write to it, and close the file. """

        if not isinstance(data, six.text_type):
            raise TypeError(
                'data must be %s, not %s' %
                (six.text_type.__class__.__name__, data.__class__.__name__))
        with self.open(mode='w', encoding=encoding, errors=errors) as f:
            return f.write(data)