     (->> xs
          serialize-wigs
          (interpose \newline)
-         (map #(.write w (str %)))
-         dorun)))
+         (run! #(.write w (str %))))))

                  (or (= format :fixed-step)
                      (= format :variable-step))))
              wigs)]}
  (letfn [(same-track? [first-wig wig]
            (and (= (-> :track :format first-wig) (-> :track :format wig))
                 (= (- (:end first-wig) (:start first-wig))
                    (- (:end wig) (:start wig)))))
          (serialize [wigs]
            (lazy-seq
             (when-first [wig wigs]
               (let [[track rest-wigs] (split-with (partial same-track? wig)
                                                   wigs)
                     track (case (-> track first :track :format)
                             :variable-step
                             (let [{:keys [chr start end]} (first track)
                                   span (inc (- end start))
                                   track-line (-> track :track :line)
                                   declaration-line (->> (cond-> ["variableStep"
                                                                  (str "chrom=" chr)]
                                                           (not= span 1)
                                                           (conj (str "span=" span)))
                                                         (cstr/join \space))
                                   data-lines (->> track
                                                   (map (fn [{:keys [start value]}]
                                                          (cstr/join \space
                                                                     [start value])))
                                                   (cstr/join \newline))]
                               (cstr/join \newline
                                          (cond-> [declaration-line data-lines]
                                            track-line (cons track-line))))

                             :fixed-step
                             (let [{:keys [chr start end]} (first track)
                                   step (- (-> track second :start) start)
                                   span (inc (- end start))
                                   track-line (-> track :track :line)
                                   declaration-line (->> (cond-> ["fixedStep"
                                                                  (str "chrom=" chr)
                                                                  (str "start=" start)]
                                                           (not= step 1)
                                                           (conj (str "step=" step))

                                                           (not= span 1)
                                                           (conj (str "span=" span)))
                                                         (cstr/join \space))
                                   data-lines (->> track
                                                   (map (fn [{:keys [value]}] value))
                                                   (cstr/join \newline))]
                               (cstr/join \newline
                                          (cond-> [declaration-line data-lines]
                                            track-line (cons track-line)))))]
                 (cons track (serialize rest-wigs))))))]
    (serialize wigs)))

(defn read-fields

                         step (as-long step)
                         pre-start (- (as-long start) step)
                         span (as-long span)
                         track (assoc track :format :fixed-step
                                            :chr chrom
                                            :span span
                                            :step step)]
                     (deserialize (rest lines) pre-start track))

                   ; data line
