/** attempt to close the VCF file */
  public void close() {
    try {
      // close the underlying output stream
      outputStream.close();

      // close the index stream (keep it separate to help debugging efforts)
      if (indexer != null) {
        final Index index = indexer.finalizeIndex(positionalOutputStream.getPosition());
        setIndexSequenceDictionary(index, refDict);
        index.write(idxStream);
        idxStream.close();
      }

    } catch (IOException e) {
      throw new RuntimeException("Unable to close index for " + getStreamName(), e);
    }
  }
 /**
  * add a record to the file
  *
  * @param vc the Variant Context object
  */
 public void add(final VariantContext vc) {
   // if we are doing on the fly indexing, add the record ***before*** we write any bytes
   if (indexer != null) indexer.addFeature(vc, positionalOutputStream.getPosition());
 }