diff --git a/src/OutputByOrbit.cc b/src/OutputByOrbit.cc
index e5e1f9fabb3a70756c3da83ca09876411fe74245..4c89b68d3bd1a68f1f5871097c9d6ad06b162ae9 100644
--- a/src/OutputByOrbit.cc
+++ b/src/OutputByOrbit.cc
@@ -32,7 +32,7 @@ void OutputByOrbitStream::OutputFixedOrbits(Slice &out) {
       if (!out.isInitialized()) {
         return;
       }
-      auto file = output_file_handler_.getFile(control_.run_number, index);
+      auto file = output_file_handler_.GetFile(control_.run_number, index);
       size_t n = file->Write(out.begin(), out.size());
       output_file_handler_.upFileSize(n);
       output_file_handler_.upNOrbits(conf_.num_orbits_per_packet_);
@@ -41,8 +41,8 @@ void OutputByOrbitStream::OutputFixedOrbits(Slice &out) {
       // file to close
       LOG(TRACE) << "the run was stopped. queueing the last file for close and "
                     "rename ";
+      //      output_file_handler_.write_EoR_file();
       output_file_handler_.enqueue_current_file_for_close_and_move_maybe();
-      // TODO: Need to write EoR file here, probably.
     }
   }
 }
diff --git a/src/OutputFileHandler.cc b/src/OutputFileHandler.cc
index 37a9b37ee7423593a523e8f99c68aa6f474bcfd1..1b6e176508ce0ca4b0bf9d0847816d17151d3ced 100644
--- a/src/OutputFileHandler.cc
+++ b/src/OutputFileHandler.cc
@@ -46,28 +46,39 @@ void OutputFileHandler::enqueue_current_file_for_close_and_move_maybe() {
   }
 }
 
-std::shared_ptr<OutputFile>& OutputFileHandler::getFile(uint32_t run, uint32_t index) {
+bool OutputFileHandler::MaybeCommitFile(uint32_t run, uint32_t index) {
   bool is_new_run = (current_run_number_ != static_cast<int>(run));
   bool is_new_index = (current_index_ != static_cast<int>(index));
 
-  // TODO: We should maybe move this out of this function...
-  if (current_run_number_ > 0 && is_new_run && getCMSSWHeaders()) {
-    OutputFileHandler::write_EoR_file();
+  if (current_run_number_ >= 0 && is_new_run) {
+    // Write by default even without cmssw headers present
+    write_EoR_file();
   }
 
-  if (is_new_run || is_new_index) {
+  bool do_commit_file = is_new_run || is_new_index;
+
+  if (do_commit_file) {
     enqueue_current_file_for_close_and_move_maybe();
-    if (is_new_run) {
-      run_NOrbits_ = 0;
-      LOG(TRACE) << "Previous run: " << current_run_number_ << " | New run: " << run;
-    }
-    if (is_new_index) {
-      LOG(TRACE) << "Previous index: " << current_index_ << " | New index: " << index;
-    }
+  }
 
-    current_index_ = static_cast<int>(index);
+  if (new_run) {
+    LOG(TRACE) << "Previous run: " << current_run_number_ << " | New run: " << run;
+    LOG(TRACE) << "Previous index: " << current_index_ << " | New index: " << index;
+
+    run_NOrbits_ = 0;
     current_run_number_ = static_cast<int>(run);
+    current_index_ = static_cast<int>(index);
     run_dir_ = base_path_ + "/" + GetRunFormatted(current_run_number_);
+  } else if (is_new_index) {
+    LOG(TRACE) << "Previous index: " << current_index_ << " | New index: " << index;
+    current_index_ = static_cast<int>(index);
+  }
+
+  return do_commit_file;
+}
+
+std::shared_ptr<OutputFile>& OutputFileHandler::GetFile(uint32_t run, uint32_t index) {
+  if (MaybeCommitFile(run, index)) {
     open_new_file();
   }
   return outputFile_;
@@ -199,7 +210,8 @@ void OutputFileHandler::write_EoR_file() {
   assert(current_index_ > 0 && nOrbitsPerFile_ > 0);
   int ls = int(1) + (current_index_ * nOrbitsPerFile_) / constants::N_orbits_per_lumisection;
   std::stringstream EoR_filename;
-  EoR_filename << run_dir_ << "/" << GetRunFormatted(current_run_number_) << "_ls0000_EoR.jsn";
+  EoR_filename << run_dir_ << "/" << GetRunFormatted(current_run_number_) << "_"
+               << GetLumiFormatted(0) << "_EoR.jsn";
   LOG(TRACE) << "Writing EoR file " << EoR_filename.str();
   std::fstream EoR_file;
   EoR_file.open(EoR_filename.str().c_str(), std::ios_base::out);
diff --git a/src/OutputFileHandler.h b/src/OutputFileHandler.h
index 7d27baa97cb218c2c616c26dc059644337725e3d..1a0a07dc5ca807916f48401192c231a18e63f9ee 100644
--- a/src/OutputFileHandler.h
+++ b/src/OutputFileHandler.h
@@ -71,7 +71,7 @@ class OutputFileHandler {
 
   void enqueue_current_file_for_close_and_move_maybe();
 
-  std::shared_ptr<OutputFile> &getFile(uint32_t run, uint32_t index);
+  std::shared_ptr<OutputFile> &GetFile(uint32_t run, uint32_t index);
 
   bool HasOpenFile() { return outputFile_->IsOpen(); }