code: def writefile(filename, data, binary=False):
      
      try:
          flags = 'w' if not binary else 'wb'
          with open(filename, flags) as _file:
              _file.write(data)
              _file.flush()
              return True
  
      except (OSError, IOError):
          return False
docs: Write the provided data to the file.
  
          `filename`
              Filename to write.
          `data`
              Data buffer to write.
          `binary`
              Set to ``True`` to indicate a binary file.
  
          Returns boolean.