Index: trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc	(revision 4826)
+++ trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc	(revision 4889)
@@ -24,26 +24,25 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MWriteAsciiFile                                                         //
-//                                                                         //
-// If you want to store a single container into an Ascii file you have     //
-// to use this class. You must know the name of the file you wanne write   //
-// (you should know it) and the name of the container you want to write.   //
-// This can be the name of the class or a given name, which identifies     //
-// the container in a parameter container list (MParList).                 //
-// The container is written to the ascii file if its ReadyToSave flag is   //
-// set (MParContainer)                                                     //
-//                                                                         //
-// You can write more than one container in one line of the file, see      //
-// AddContainer.                                                           //
-//                                                                         //
-// You can also write single data members of a container (like fWidth      //
-// of MHillas). For more details see AddContainer. Make sure, that a       //
-// getter method for the data member exist. The name of the method         //
-// must be the same than the data member itself, but the f must be         //
-// replaced by a Get.                                                      //
-//                                                                         //
+//
+// MWriteAsciiFile
+//
+// If you want to store a single container into an Ascii file you have
+// to use this class. You must know the name of the file you wanne write
+// (you should know it) and the name of the container you want to write.
+// This can be the name of the class or a given name, which identifies
+// the container in a parameter container list (MParList).
+// The container is written to the ascii file if its ReadyToSave flag is
+// set (MParContainer)
+//
+// You can write more than one container in one line of the file, see
+// AddContainer.
+//
+// You can also write single data members of a container (like fWidth
+// of MHillas). For more details see AddContainer. Make sure, that a
+// getter method for the data member exist. The name of the method
+// must be the same than the data member itself, but the f must be
+// replaced by a Get.
+//
 /////////////////////////////////////////////////////////////////////////////
-
 #include "MWriteAsciiFile.h"
 
@@ -51,4 +50,6 @@
 
 #include <TMethodCall.h> // TMethodCall, AsciiWrite
+
+#include "MIter.h"
 
 #include "MDataList.h"   // MDataList
@@ -190,18 +191,32 @@
 Bool_t MWriteAsciiFile::CheckAndWrite()
 {
+    MParContainer *obj = NULL;
+
+    //
+    // Check for the Write flag
+    //
+    Bool_t write = kFALSE;
+    MIter Next(&fList);
+    while ((obj=Next()))
+        if (obj->IsReadyToSave())
+        {
+            write = kTRUE;
+            break;
+        }
+
+    //
+    // Do not write if not at least one ReadyToSave-flag set
+    //
+    if (!write)
+        return kTRUE;
+
     Bool_t written = kFALSE;
-
-    MParContainer *obj = NULL;
-
     Int_t num = fList.GetEntries();
 
-    TIter Next(&fList);
-    while ((obj=(MParContainer*)Next()))
+    Next.Reset();
+    while ((obj=Next()))
     {
-        //
-        // Check for the Write flag
-        //
-        if (!obj->IsReadyToSave())
-            continue;
+        if (written)
+            *fOut << " ";
 
         //
@@ -224,5 +239,5 @@
 
         if (num!=0)
-            *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl;
+            *fLog << warn << "WARNING - Number of objects written mismatch!" << endl;
     }
     return kTRUE;
