Index: trunk/psLib/src/fits/psFitsHeader.c
===================================================================
--- trunk/psLib/src/fits/psFitsHeader.c	(revision 7295)
+++ trunk/psLib/src/fits/psFitsHeader.c	(revision 7297)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-02 19:50:48 $
+ *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-06-02 20:59:57 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -36,5 +36,5 @@
 
 // List of FITS header keys not to write (handled by cfitsio); NULL-terminated
-static char *noWriteFitsKeys[] = {"XTENSION", "BITPIX", "NAXIS", "EXTNAME", "BSCALE", "BZERO",
+static char *noWriteFitsKeys[] = {"SIMPLE", "XTENSION", "BITPIX", "NAXIS", "EXTNAME", "BSCALE", "BZERO",
                                   "TFIELDS", NULL};
 // List of the start of FITS header keys not to write (handled by cfitsio); NULL-terminated
@@ -250,25 +250,29 @@
                            )
 {
+    int status = 0;                     // Status of cfitsio calls
+    bool simple = true;                 // If SIMPLE is T, then the file should conform to the FITS standard
+    psMetadataItem *simpleItem = psMetadataLookup(output, "SIMPLE"); // SIMPLE in the header
+    if (simpleItem) {
+        // We allow the user to write SIMPLE, but it must be boolean
+        if (simpleItem->type != PS_DATA_BOOL) {
+            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "SIMPLE in a FITS header must be of boolean type: "
+                    "not %x --- assuming TRUE.\n", simpleItem->type);
+            int value = false;          // Temporary holder for boolean
+            fits_update_key(fits->fd, TLOGICAL, "SIMPLE", &value,
+                            "File does not conform to FITS standard", &status);
+            simple = false;
+        } else if (!simpleItem->data.B) {
+            simple = false;
+            int value = false;          // Temporary holder for boolean
+            fits_update_key(fits->fd, TLOGICAL, "SIMPLE", &value,
+                            "File does not conform to FITS standard", &status);
+        }
+        // SIMPLE = T is taken care of by cfitsio.
+    }
+
     // Traverse the metadata list and add each key.
     psListIterator* iter = psListIteratorAlloc(output->list, PS_LIST_HEAD, true); // Iterator
     psMetadataItem* item;               // Item from iteration
-    int status = 0;                     // Status of cfitsio calls
-    bool simple = true;                 // If SIMPLE is T, then the file should conform to the FITS standard
     while ((item = psListGetAndIncrement(iter))) {
-        // We allow the user to write SIMPLE, but it must be boolean
-        if (strcmp(item->name, "SIMPLE") == 0) {
-            if (item->type != PS_DATA_BOOL) {
-                psError(PS_ERR_BAD_PARAMETER_TYPE, true, "SIMPLE in a FITS header must be of boolean type: "
-                        "not %x --- assuming FALSE.\n", item->type);
-                int value = false;      // Temporary
-                fits_update_key(fits->fd, TLOGICAL, "SIMPLE", &value,
-                                "File does not conform to FITS standard", &status);
-                simple = false;
-                continue;
-            } else if (! item->data.B) {
-                simple = false;
-            }
-        }
-
         // Check to see if the item should be ignored
         if (simple) {
