code: def close(self):
      
      if not self.closed:
        self.closed = True
        self._flush(finish=True)
        self._buffer = None
docs: Flush the buffer and finalize the file.
  
      When this returns the new file is available for reading.