'Force a write of the `HDUList` back to the file (for append and
update modes only).
Parameters
output_verify : str
Output verification option.  Must be one of ``"fix"``,
``"silentfix"``, ``"ignore"``, ``"warn"``, or
``"exception"``.  May also be any combination of ``"fix"`` or
``"silentfix"`` with ``"+ignore"``, ``+warn``, or ``+exception"
(e.g. ``"fix+warn"``).  See :ref:`verify` for more info.
verbose : bool
When `True`, print verbose messages'

@ignore_sigint
def flush(self, output_verify='fix', verbose=False):

    if (self._file.mode not in ('append', 'update', 'ostream')):
        warnings.warn("Flush    for    '{}'    mode    is    not    supported.".format(self._file.mode), AstropyUserWarning)
        return
    if (self._save_backup and (self._file.mode in ('append', 'update'))):
        filename = self._file.name
        if os.path.exists(filename):
            backup = (filename + '.bak')
            idx = 1
            while os.path.exists(backup):
                backup = ((filename + '.bak.') + str(idx))
                idx += 1
            warnings.warn('Saving    a    backup    of    {}    to    {}.'.format(filename, backup), AstropyUserWarning)
            try:
                shutil.copy(filename, backup)
            except IOError as exc:
                raise IOError('Failed    to    save    backup    to    destination    {}:    {}'.format(filename, exc))
    self.verify(option=output_verify)
    if (self._file.mode in ('append', 'ostream')):
        for hdu in self:
            if verbose:
                try:
                    extver = str(hdu._header['extver'])
                except KeyError:
                    extver = ''
            if hdu._new:
                hdu._prewriteto(checksum=hdu._output_checksum)
                with _free_space_check(self):
                    hdu._writeto(self._file)
                    if verbose:
                        print('append    HDU', hdu.name, extver)
                    hdu._new = False
                hdu._postwriteto()
    elif (self._file.mode == 'update'):
        self._flush_update()
