     (try
       (with-open [out (io/writer tmpfile)]
         (csv/write-csv out header)
-        (csv/write-csv out (measurements->columns (filled-measurements data))))
+        (filled-measurements data out))
       (s3/store-file (:s3 store) (-> item
                                      (assoc :dir      (.getParent tmpfile)
                                             :filename (.getName tmpfile))

                                                       (hash-map :timestamp row-timestamp :value nil))) row)
                fns            (map-indexed (fn [i _] (if (has-data? i) next-or-sentinel identity)) row)
                step           (fn [xs] (map (fn [f v] (f v)) fns xs))]
            (recur (step ms) (concat data [out-row]))))))))

(defn measurements->columns [ms]
  (map (fn [[x & more]] (apply vector (:timestamp x) (:value x) (map :value more))) ms))

(defn generate-file [store item]
  (let [{:keys [header data]} item

                           (when-let [row (first (apply map vector (replace-empty xs)))]
                             (when (not-every? is-sentinel? row)
                               row)))]
    (loop [ms measurements]
      (let [row (next-row ms)]
        (when row
          (let [row-timestamps (mapv :timestamp row)
                row-timestamp  (first (sort (remove nil? row-timestamps)))
                data-indexes   (indexes-of row-timestamp row-timestamps)
