Index: trunk/FACT++/src/csv2root.cc
===================================================================
--- trunk/FACT++/src/csv2root.cc	(revision 19796)
+++ trunk/FACT++/src/csv2root.cc	(revision 19798)
@@ -398,5 +398,29 @@
         }
 
-        ttree[index]->Fill();
+        // Fill only branches for which an adress was set
+        // If we fill the tree, we get empty entries at the
+        // end of the already written branches
+        TIter NextBranch(ttree[index]->GetListOfBranches());
+        TBranch *b=0;
+        while ((b=static_cast<TBranch*>(NextBranch())))
+            if (b->GetAddress())
+                b->Fill();
+    }
+
+    for (auto it=ttree.begin(); it!=ttree.end(); it++)
+    {
+        if (update)
+        {
+            TIter NextBranch((*it)->GetListOfBranches());
+            TBranch *b=0;
+            while ((b=static_cast<TBranch*>(NextBranch())))
+                if (b->GetAddress() && b->GetEntries()>0)
+                {
+                    (*it)->SetEntries(b->GetEntries());
+                    break;
+                }
+        }
+
+        (*it)->Write("", TObject::kOverwrite);
     }
 
@@ -404,9 +428,6 @@
     {
         cout << valid << " data rows found in " << line << " lines (excl. title)." << endl;
-        if (!update || !entries)
-        {
-            for (size_t i=0; i<ttree.size(); i++)
-                cout << ttree[i]->GetEntries() << " rows filled into tree #" << i << "." << endl;
-        }
+        for (size_t i=0; i<ttree.size(); i++)
+            cout << ttree[i]->GetEntries() << " rows filled into tree #" << i << "." << endl;
     }
 
@@ -414,6 +435,4 @@
         cerr << "\nWARNING - Number of updated entries does not match number of entries in tree!\n" << endl;
 
-    for (auto it=ttree.begin(); it!=ttree.end(); it++)
-        (*it)->Write("", TObject::kOverwrite);
     tfile.Close();
 
