Index: branches/MarsResidualTimeSpread/mbase/MEnv.cc
===================================================================
--- branches/MarsResidualTimeSpread/mbase/MEnv.cc	(revision 18022)
+++ branches/MarsResidualTimeSpread/mbase/MEnv.cc	(revision 18037)
@@ -51,4 +51,7 @@
 #include "MEnv.h"
 
+#include <fstream>
+#include <exception>
+
 #include <Gtypes.h>
 #include <TObjString.h>
@@ -97,4 +100,9 @@
 
     SetRcName(fname);
+    
+    if (!IsTEnvCompliant(name)){
+        throw "This file can't be correctly parsed by TEnv";
+        return;
+    }
 
     // No file found
@@ -189,4 +197,54 @@
 
     return 0;
+}
+
+//---------------------------------------------------------------------------
+//
+// Check if the input file is compatible to the way TEnv parses a resource file.
+// 
+// Returns true in case everything is file and
+//         false in case there is a problem with the file.
+//
+// Background:
+//      This check has been introduced as a workaround for a ROOT feature.
+//      TEnv will not see the last line in a text file, when this last line 
+//      does not end with a \n.
+//
+//      In addition we check for the occurence of \r, since some editors would
+//      place \r instead of \n (unlike windows that uses \n\r), which would
+//      also result in problems.
+//      FIXME: So currently we also complain about "\n\r" and "\r\n" as well as 
+//      "\r  \t   \n" or "\n      \t\t\t\r", which would in fact not be a problem at 
+//      all.
+Bool_t MEnv::IsTEnvCompliant(const char *fname)
+{
+    ifstream ifs(fname);
+    bool printable_char_since_last_lf = false;
+    char c;
+    while (ifs.good()){
+        ifs.get(c);
+
+        if (c==13){
+            gLog << err << "Menv::IsTEnvCompliant - file:" << fname 
+                << " contains \\r this might lead to parsing errors. "
+                <<"Please exchange \\r by \\n everywhere in that file." 
+                << endl;
+            return false;
+        }
+        if (c=='\n'){
+            printable_char_since_last_lf = false;
+        }
+        if (isgraph(c)){
+            printable_char_since_last_lf = true;
+        }
+    }
+    if (printable_char_since_last_lf){
+        gLog << err << "Menv::IsTEnvCompliant - file:" << fname 
+            << " must have \\n at the end of the file. "
+            <<"Please make sure this is the case." 
+            << endl;
+        return false;
+    }
+    return true;
 }
 
Index: branches/MarsResidualTimeSpread/mbase/MEnv.h
===================================================================
--- branches/MarsResidualTimeSpread/mbase/MEnv.h	(revision 18022)
+++ branches/MarsResidualTimeSpread/mbase/MEnv.h	(revision 18037)
@@ -27,4 +27,5 @@
     TString Compile(TString str, const char *post) const;
     Int_t   ReadInclude();
+    Bool_t  IsTEnvCompliant(const char *fname);
 
 public:
Index: branches/MarsResidualTimeSpread/mcore/factofits.h
===================================================================
--- branches/MarsResidualTimeSpread/mcore/factofits.h	(revision 18022)
+++ branches/MarsResidualTimeSpread/mcore/factofits.h	(revision 18037)
@@ -224,4 +224,5 @@
             c.SetStr(  "RAWSUM",   "         0",    "Checksum of raw little endian data");
             c.SetFloat("ZRATIO",   0,               "Compression ratio");
+
             c.SetInt(  "ZSHRINK",  1,               "Catalog shrink factor");
             c.End();
@@ -280,5 +281,9 @@
             //update relevant keywords
             c.SetFloat("ZRATIO", (float)(1024*1440*2)/(float)(compressed_size));
-            c.SetInt("PCOUNT", compressed_size + catalog_size);
+            c.SetInt("PCOUNT", compressed_size);// + catalog_size);
+
+
+//cout << "DEBUG: compressed_size=" << compressed_size << " " << compressed_size%2880 << " " << catalog_size << endl;
+
 
 #if GCC_VERSION < 40603
@@ -302,4 +307,5 @@
             return good();
         }
+
         ///Apply the drs offset calibration (overload of super-method)
         virtual void DrsOffsetCalibrate(char* target_location)
