                             (conj linear-index new-linear-index)))
                    [bin-index linear-index]))]
     {:n-seq n-seq, :preset preset, :sc sc, :bc bc, :ec ec, :meta meta,
-     :skip skip, :bin-index (first index), :linear-index (last index)}
-    ))
-
-(deftype TABIXReader [f ^DataInputStream reader]
-  java.io.Closeable
-  (close [this]
-    (.close ^DataInputStream (.reader this))))
+     :skip skip, :seq seq ,:bin-index (first index), :linear-index (last index)}))
 
 (defn read-index
-  [^TABIXReader rdr]
-  (read-index* (.reader rdr)))
-
-(defn reader [f]
-  (->TABIXReader f (DataInputStream. (BGZFInputStream. (io/file f)))))
+  [f]
+  (with-open [r (DataInputStream. (BGZFInputStream. (io/file f)))]
+    (read-index* r)))

  (:import java.util.Arrays
           [java.io DataInputStream IOException]
           bgzf4j.BGZFInputStream))

(set! *warn-on-reflection* true)

(def tabix-magic "TBI\1")


        skip   (lsb/read-int rdr)
        len    (lsb/read-int rdr)
        buf    (lsb/read-bytes rdr len)
        seq    (read-seq buf len)
        index  (loop [i 0
                      bin-index []
                      linear-index []]
