docs: def to_file(self, fname, comments=None, compress_with='use_ext'):
          """
              The method is for saving a CNF formula into a file in the DIMACS
              CNF format. A file name is expected as an argument. Additionally,
              supplementary comment lines can be specified in the ``comments``
              parameter. Also, a file can be compressed using either gzip, bzip2,
              or lzma (xz).
  
              :param fname: a file name where to store the formula.
              :param comments: additional comments to put in the file.
              :param compress_with: file compression algorithm
  
              :type fname: str
              :type comments: list(str)
              :type compress_with: str
  
              Note that the ``compress_with`` parameter can be ``None`` (i.e.
              the file is uncompressed), ``'gzip'``, ``'bzip2'``, ``'lzma'``, or
              ``'use_ext'``. The latter value indicates that compression type
              should be automatically determined based on the file extension.
              Using ``'lzma'`` in Python 2 requires the ``backports.lzma``
              package to be additionally installed.
  
              Example:
  
              .. code-block:: python
  
                  >>> from pysat.formula import CNF
                  >>> cnf = CNF()
                  ...
                  >>> # the formula is filled with a bunch of clauses
                  >>> cnf.to_file('some-file-name.cnf')  # writing to a file
          """
  
          with FileObject(fname, mode='w', compression=compress_with) as fobj:
              self.to_fp(fobj.fp, comments)