'Implements flushing changes to a file in update mode.'

def _flush_update(self):

    for hdu in self:
        hdu._prewriteto(checksum=hdu._output_checksum, inplace=True)
    try:
        self._wasresized()
        if (self._resize or self._file.compression):
            self._flush_resize()
        else:
            for hdu in self:
                hdu._writeto(self._file, inplace=True)
        for hdu in self:
            hdu._header._modified = False
    finally:
        for hdu in self:
            hdu._postwriteto()
