Index: trunk/psModules/src/camera/pmFPAfileFitsIO.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfileFitsIO.c	(revision 14204)
+++ trunk/psModules/src/camera/pmFPAfileFitsIO.c	(revision 15180)
@@ -471,24 +471,30 @@
     if (file->wrote_phu) return true;
 
-    // select or generate the desired fpa in the correct output format 
+    // select or generate the desired fpa in the correct output format
     pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config);
+    pmHDU *phu = pmFPAviewThisHDU(view, fpa);
+    if (!phu || !phu->blankPHU) {
+        // No PHU to write!
+        psFree(fpa);
+        return true;
+    }
 
     switch (file->fileLevel) {
       case PM_FPA_LEVEL_FPA:
-	status = pmFPAWrite(fpa, file->fits, NULL, true, false);
-	break;
+        status = pmFPAWrite(fpa, file->fits, NULL, true, false);
+        break;
       case PM_FPA_LEVEL_CHIP: {
-	  pmChip *chip = pmFPAviewThisChip(view, fpa);
-	  status = pmChipWrite(chip, file->fits, NULL, true, false);
-	  break;
+          pmChip *chip = pmFPAviewThisChip(view, fpa);
+          status = pmChipWrite(chip, file->fits, NULL, true, false);
+          break;
       }
       case PM_FPA_LEVEL_CELL: {
-	  pmCell *cell = pmFPAviewThisCell(view, fpa);
-	  status = pmCellWrite(cell, file->fits, NULL, true);
-	  break;
+          pmCell *cell = pmFPAviewThisCell(view, fpa);
+          status = pmCellWrite(cell, file->fits, NULL, true);
+          break;
       }
       default:
-	psAbort("fileLevel not correctly set");
-	break;
+        psAbort("fileLevel not correctly set");
+        break;
     }
 
