Index: trunk/ppStack/src/ppStackFinish.c
===================================================================
--- trunk/ppStack/src/ppStackFinish.c	(revision 26898)
+++ trunk/ppStack/src/ppStackFinish.c	(revision 27059)
@@ -79,10 +79,17 @@
         const char *statsMDC = psMetadataConfigFormat(options->stats);
         if (!statsMDC || strlen(statsMDC) == 0) {
-            psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n");
-        } else {
-            fprintf(options->statsFile, "%s", statsMDC);
+            psError(PS_ERR_IO, false, "Unable to get statistics MDC file.");
+            return false;
+        }
+        if (fprintf(options->statsFile, "%s", statsMDC) != strlen(statsMDC)) {
+            psError(PS_ERR_IO, false, "Unable to write statistics MDC file.");
+            return false;
         }
         psFree(statsMDC);
-        fclose(options->statsFile); options->statsFile = NULL;
+        if (fclose(options->statsFile) == EOF) {
+            psError(PS_ERR_IO, false, "Unable to close statistics MDC file.");
+            return false;
+        }
+        options->statsFile = NULL;
         pmConfigRunFilenameAddWrite(config, "STATS", psMetadataLookupStr(NULL, config->arguments, "STATS"));
     }
@@ -92,5 +99,5 @@
     if (dump) {
         if (!pmConfigDump(config, dump)) {
-            psError(PS_ERR_IO, false, "Unable to dump configuration.");
+            psError(psErrorCodeLast(), false, "Unable to dump configuration.");
             return false;
         }
