code: def write(self, buf, newline=True):
          
  
          buf = buf or ''
  
          if newline:
              buf += os.linesep
  
          try:
              self._output.write(buf)
  
              if hasattr(self._output, 'flush'):
                  self._output.flush()
  
          except IOError as exc:
              if exc.errno != errno.EPIPE:  # silence EPIPE errors
                  raise
docs: Writes buffer to output stream.
  
              `buf`
                  Data buffer to write.
              `newline`
                  Append newline character to buffer before writing.