<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def close(self):
 """Flush the buffer and finalize the file. When this returns the new file is available for reading. """

    if not self.closed:
      self.closed = True
      self._flush(finish=True)
      self._buffer = None