Index: /trunk/Mars/mcore/ofits.h
===================================================================
--- /trunk/Mars/mcore/ofits.h	(revision 13997)
+++ /trunk/Mars/mcore/ofits.h	(revision 13998)
@@ -608,5 +608,5 @@
         h.SetInt ("NAXIS",     0, "number of data axes");
         h.SetBool("EXTEND", true, "FITS dataset may contain extensions");
-        h.SetStr ("CHECKSUM","4AcB48bA4AbA45bA", "Checksum for the whole HDU");
+        h.SetStr ("CHECKSUM","0000000000000000", "Checksum for the whole HDU");
         h.SetStr ("DATASUM", "         0", "Checksum for the data block");
         h.AddComment("FITS (Flexible Image Transport System) format is defined in 'Astronomy");
@@ -614,5 +614,13 @@
         h.End();
 
-        return h.WriteHeader(*this);
+        Checksum sum = h.WriteHeader(*this);
+        size_t offset = tellp();
+        h.SetStr("CHECKSUM", sum.str());
+        //header gets updated here. cannot direcly return this otherwise
+        //1. wrong checksum would be returned (does not matter... now)
+        //2. cannot restore the correct location of the file's cursor
+        h.WriteHeader(*this);
+        seekp(offset);
+        return sum;
     }
 
