code: def Write(self, string):
      
      try:
        # Note that encode() will first convert string into a Unicode string
        # if necessary.
        encoded_string = codecs.encode(string, self._encoding, self._errors)
      except UnicodeEncodeError:
        if self._errors == 'strict':
          logger.error(
              'Unable to properly write output due to encoding error. '
              'Switching to error tolerant encoding which can result in '
              'non Basic Latin (C0) characters to be replaced with "?" or '
              '"\\ufffd".')
          self._errors = 'replace'
  
        encoded_string = codecs.encode(string, self._encoding, self._errors)
  
      self._file_object.write(encoded_string)
docs: Writes a string to the output.
  
      Args:
        string (str): output.