                   (letfn [(through-remainder [n offset]
                             (if (or (zero? n)
                                     (neg? (compare chrom
-                                                   (lsb/read-string r key-size))))
+                                                   (read-c-style-string r key-size))))
                               offset
                               (recur (dec n) (lsb/read-ushort r))))]
                     (recur (through-remainder (dec child-count)

              (if leaf?
                (letfn [(read-leaves [n]
                          (when-not (zero? n)
                            (let [key (lsb/read-string r key-size)
                                  id (lsb/read-uint r)
                                  _size (lsb/read-uint r)]
                              (if (zero? (compare chrom key))

     fixed-width-header zoom-headers total-summary extended-header bpt-header
     bbi-chrom-info cir-tree)))

(defn- read-c-style-string
  "Reads `length` bytes and returns a string. This function is useful for
  handling c-style null-terminated string."
  [^RandomAccessFile r ^long length]
  (->> (lsb/read-bytes r length)
       (reduce
        (fn [cs c]
          (if (zero? c)
            (reduced cs)
            (conj cs c)))
        [])
       (map char)
       (apply str)))

(defn- read-bbi-chrom-info-leaves
  "Returns the BbiChromInfo data of leaves."
  [^RandomAccessFile r key-size child-count]
  (repeatedly child-count
              (fn []
                (let [name (read-c-style-string r key-size)
                      id (lsb/read-uint r)
                      size (lsb/read-uint r)]
                  (BbiChromInfo.
