code: def create_new_output_file(sampler, filename, force=False, injection_file=None,
                             **kwargs):
      
      if os.path.exists(filename):
          if force:
              os.remove(filename)
          else:
              raise OSError("output-file already exists; use force if you "
                            "wish to overwrite it.")
      logging.info("Creating file {}".format(filename))
      with sampler.io(filename, "w") as fp:
          # create the samples group and sampler info group
          fp.create_group(fp.samples_group)
          fp.create_group(fp.sampler_group)
          # save the sampler's metadata
          fp.write_sampler_metadata(sampler)
          # save injection parameters
          if injection_file is not None:
              logging.info("Writing injection file to output")
              # just use the first one
              fp.write_injections(injection_file)
docs: Creates a new output file.
  
      If the output file already exists, an ``OSError`` will be raised. This can
      be overridden by setting ``force`` to ``True``.
  
      Parameters
      ----------
      sampler : sampler instance
          Sampler
      filename : str
          Name of the file to create.
      force : bool, optional
          Create the file even if it already exists. Default is False.
      injection_file : str, optional
          If an injection was added to the data, write its information.
      \**kwargs :
          All other keyword arguments are passed through to the file's
          ``write_metadata`` function.