code: def flush(self):
          
          self._check_open_file()
          if self.allow_update and not self.is_stream:
              contents = self._io.getvalue()
              if self._append:
                  self._sync_io()
                  old_contents = (self.file_object.byte_contents
                                  if is_byte_string(contents) else
                                  self.file_object.contents)
                  contents = old_contents + contents[self._flush_pos:]
                  self._set_stream_contents(contents)
                  self.update_flush_pos()
              else:
                  self._io.flush()
              if self.file_object.set_contents(contents, self._encoding):
                  if self._filesystem.is_windows_fs:
                      self._changed = True
                  else:
                      current_time = time.time()
                      self.file_object.st_ctime = current_time
                      self.file_object.st_mtime = current_time
              self._file_epoch = self.file_object.epoch
  
              if not self.is_stream:
                  self._flush_related_files()
docs: Flush file contents to 'disk'.