Index: /trunk/Mars/mbase/MEnv.cc
===================================================================
--- /trunk/Mars/mbase/MEnv.cc	(revision 18017)
+++ /trunk/Mars/mbase/MEnv.cc	(revision 18018)
@@ -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: /trunk/Mars/mbase/MEnv.h
===================================================================
--- /trunk/Mars/mbase/MEnv.h	(revision 18017)
+++ /trunk/Mars/mbase/MEnv.h	(revision 18018)
@@ -27,4 +27,5 @@
     TString Compile(TString str, const char *post) const;
     Int_t   ReadInclude();
+    Bool_t  IsTEnvCompliant(const char *fname);
 
 public:
