Index: trunk/psModules/src/concepts/pmConceptsWrite.c
===================================================================
--- trunk/psModules/src/concepts/pmConceptsWrite.c	(revision 8815)
+++ trunk/psModules/src/concepts/pmConceptsWrite.c	(revision 8848)
@@ -5,5 +5,5 @@
 #include <stdio.h>
 #include <assert.h>
-#include <strings.h>
+#include <string.h>
 #include <pslib.h>
 
@@ -132,13 +132,17 @@
 static bool writeSingleHeader(pmHDU *hdu, // HDU for which to add to the header
                               const char *keyword, // Keyword to add
-                              psMetadataItem *item // Item to add to the header
+                              psMetadataItem *item // Item to add to the header; may be NULL
                              )
 {
     assert(hdu);
     assert(keyword && strlen(keyword) > 0);
-    assert(item);
 
     if (!hdu->header) {
         hdu->header = psMetadataAlloc();
+    }
+    if (!item) {
+        psTrace("psModules.concepts", 9, "Writing header %s: <<<BLANK>>>\n", keyword);
+        // Assume it's a NULL string: it's most easily parsed.
+        return psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, NULL, NULL);
     }
     switch (item->type) {
@@ -188,18 +192,16 @@
     if (item->type == PS_DATA_LIST) {
         psList *values = item->data.V;  // List of outputs
-        if (values->n == 0) {
-            // Nothing to write
+        psList *keys = psStringSplit(keywords, " ,;", true); // List of keywords
+        if (keys->n != values->n && values->n != 0) {
+            psError(PS_ERR_UNKNOWN, true, "Number of keywords (%ld) does not match number of "
+                    "values (%ld).\n", keys->n, values->n);
+            psFree(keys);
             return false;
-        }
-        psList *keys = psStringSplit(keywords, " ,;", true); // List of keywords
-        if (keys->n != values->n) {
-            psLogMsg(__func__, PS_LOG_WARN, "Number of keywords (%ld) does not match number of values (%ld).\n",
-                     keys->n, values->n);
         }
         psListIterator *keysIter = psListIteratorAlloc(keys, PS_LIST_HEAD, false); // Iterator for keywords
         psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator for values
         psString key = NULL;            // Keyword from iteration
-        psMetadataItem *value = NULL;   // Value from iteration
-        while ((key = psListGetAndIncrement(keysIter)) && (value = psListGetAndIncrement(valuesIter))) {
+        while ((key = psListGetAndIncrement(keysIter))) {
+            psMetadataItem *value = psListGetAndIncrement(valuesIter); // Value from iteration; may be NULL
             status |= writeSingleHeader(hdu, key, value);
         }
@@ -394,28 +396,6 @@
                 continue;
             }
-            psList *keywords = psStringSplit(headerItem->data.V, " ,;", true); // List of header keywords
-            if (formatted->type == PS_DATA_LIST) {
-                psList *values = formatted->data.V; // The values for the headers
-                if (values->n != keywords->n) {
-                    psLogMsg(__func__, PS_LOG_WARN, "Number of headers specified does not match number "
-                             "of values for concept %s.\n", name);
-                }
-                psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator
-                psListIterator *keywordsIter = psListIteratorAlloc(keywords, PS_LIST_HEAD, false);
-                psMetadataItem *valuesItem = NULL; // Item from list
-                while ((valuesItem = psListGetAndIncrement(valuesIter))) {
-                    psString keyword = psListGetAndIncrement(keywordsIter); // Keyword from the list
-                    if (strlen(keyword) > 0) {
-                        writeHeader(hdu, keyword, formatted);
-                    }
-                }
-                psFree(valuesIter);
-                psFree(keywordsIter);
-            } else {
-                psString keyword = psListGet(keywords, PS_LIST_HEAD); // The keyword
-                writeHeader(hdu, keyword, formatted);
-            }
+            writeHeader(hdu, headerItem->data.V, formatted);
             psFree(formatted);
-            psFree(keywords);
         }
     }
