 (defn write-header
   [buffer count]
   (pad buffer 0 stl-file/MESSAGE_LENGTH)
-  (.putInt buffer 0 count)
+  (.putInt buffer stl-file/MESSAGE_LENGTH count)
   stl-file/HEADER_LENGTH)
 
 (defn write-facet

        post_vertices_offset (process_vertices buffer
                                               post_normal_offset
                                               (:vertices facet))]
    pad buffer post_vertices_offset 2))

(defn calculate-file-size
  [num_facets]
  (+ stl-file/HEADER_LENGTH (* num_facets stl-file/BYTES_PER_FACET)))

(defn write-stl
  [stl-seq ^String filename]

   [stl-collector.model :as stl]
   [stl-collector.file :as stl-file]
   [clojure.java.io :as io]
   [nio.core :as nio])
  
  (:import (java.nio ByteOrder DirectByteBuffer)))

(defn pad [buffer offset num_bytes]
  (if (> num_bytes 0)
