diff --git a/src/outputByOrbit.cc b/src/outputByOrbit.cc
index 9f2736362c89c705cc961469be5b137cb8192832..afac85b1003d63401fa8f0cb04ffbee137c83e9c 100644
--- a/src/outputByOrbit.cc
+++ b/src/outputByOrbit.cc
@@ -82,10 +82,10 @@ void* OutputByOrbitStream::OutputFixedOrbits( Slice& out ) {
 	n = fwrite( out.begin(), 1, out.size(), outFile.getFile() );
 
       } 
+      current_file_size +=n;    
+    }else{ // i.e should not currently be writing data
+      close_and_move_file();//once for each open file (should be 2)
     }
-    current_file_size +=n;    
-  }else{ // i.e should not currently be writing data
-    close_and_move_file();//once for each open file (should be 2)
   }
 }