       (catch Exception e (error e e)))
     (let [file2 (File. future-file-name)]
       (if (.exists file2)
-        (close-and-roll file-data (inc i))
+        (close-and-roll (assoc file-data :future-file-name (create-future-file-name file i)) (inc i))
         (do
           (info "Rename " (.getName file) " to " (.getName file2))
           (.renameTo file file2)

                            "_" (System/nanoTime))))


  (defn- create-future-file-name
    "Create the filename that would be written once the file has been rolled"
    [file]
    (.getParent ^File (clojure.java.io/file file))
                       ^String (add-file-name-index
                         (clj-str/join "" (interpose "_" (-> (.getName file) (clj-str/split #"_") drop-last)))

      (info "create new file " (.getAbsolutePath file))
      (if (not (.exists file)) (throw (java.io.IOException. (str "Failed to create " file)))  )

      (merge {:file file :codec codec :file-key file-key :future-file-name (create-future-file-name file 0)
              :updated (AtomicReference. (System/currentTimeMillis))}
             (get-output file conf))))

