diff --git a/src/OutputFileHandler.cc b/src/OutputFileHandler.cc
index 198889baee7ef69f2e921baade4a19662a310536..fd539ad852a8b5a6cca46542fe1b30bd355678ec 100644
--- a/src/OutputFileHandler.cc
+++ b/src/OutputFileHandler.cc
@@ -1,3 +1,4 @@
+
 #include "OutputFileHandler.h"
 #include "log.h"
 #include "tools.h"
@@ -9,12 +10,19 @@ const std::string OutputFileHandler::journal_file_ = "index.journal";
 tbb::concurrent_bounded_queue<std::pair<std::string, FILE *>>
     OutputFileHandler::files_to_close_ =
         tbb::concurrent_bounded_queue<std::pair<std::string, FILE *>>();
-bool OutputFileHandler::file_handler_running_ = false;
+bool OutputFileHandler::file_handler_running_ = true;
 
 void OutputFileHandler::enqueue_current_file_for_close_and_move_maybe() {
-  if (current_file_ != 0)
+  if (current_file_ != 0) {
+    LOG(TRACE) << "queueing file: " << current_filename_
+               << " for closing, queue size now " << files_to_close_.size();
     files_to_close_.push(
         std::pair<std::string, FILE *>(current_filename_, current_file_));
+    current_file_ = 0;
+    current_filename_ = std::string();
+    LOG(TRACE) << "queued " << current_filename_ << " queue size now "
+               << files_to_close_.size();
+  }
 }
 
 FILE *OutputFileHandler::getFile(uint32_t run, uint32_t index) {
@@ -30,7 +38,8 @@ FILE *OutputFileHandler::getFile(uint32_t run, uint32_t index) {
 void OutputFileHandler::create_output_directory_maybe(
     std::string &output_directory) {
   struct stat sb;
-
+  LOG(TRACE) << "checking if working directory " << output_directory
+             << " exists ";
   /* check if path exists and is a directory */
   if (stat(output_directory.c_str(), &sb) == 0) {
     if (S_ISDIR(sb.st_mode)) { // output directory already exists
@@ -73,7 +82,8 @@ std::string OutputFileHandler::format_filename(uint32_t run_number,
                                                uint32_t index) {
   std::ostringstream ofilename;
   ofilename << filename_prefix_ << "_" << std::setfill('0') << std::setw(6)
-            << run_number << "_" << index << ".dat";
+            << run_number << "_" << std::setfill('0') << std::setw(6) << index
+            << ".dat";
   return ofilename.str();
 }
 
@@ -82,7 +92,10 @@ void OutputFileHandler::close_and_rename::operator()() const {
   while (file_handler_running_ || (files_to_close_.size() > 0)) {
     //	std::cout << std::this_thread::get_id() << " try pop" <<
     // files_to_close_.size() << std::endl;
+    LOG(TRACE) << "try pop now. queue size now " << files_to_close_.size();
     files_to_close_.pop(n);
+    LOG(TRACE) << "popping file: " << n.first << " for closing, queue size now "
+               << files_to_close_.size();
     if (fclose(n.second) != 0) {
       LOG(ERROR) << tools::strerror("File close failed");
     }
@@ -94,4 +107,7 @@ void OutputFileHandler::close_and_rename::operator()() const {
     //	std::cout << std::this_thread::get_id() << " popped " << n.first << "
     // size now " << files_to_close_.size() << std::endl;
   }
+  LOG(TRACE) << "exiting close_and_rename. file_handler_running_ now "
+             << file_handler_running_ << " queue size now "
+             << files_to_close_.size();
 }