diff --git a/src/files.c b/src/files.c
index e01939b1db8f5751cce14d0fcd09528b4eaf1fc6..a762a0df6d249b00a5952c44e15d15cfee0e5e24 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2243,11 +2243,10 @@ int do_writeout(bool exiting)
 	/* Whether it's okay to save the file under a different name. */
     bool result = FALSE;
 
-    if (exiting && openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
-	result = write_file(openfile->filename, NULL, FALSE, OVERWRITE, FALSE);
-
-	if (result)
-	    return 1;	/* The write succeeded. */
+    if (exiting && ISSET(TEMP_FILE) && openfile->filename[0] != '\0') {
+	if (write_file(openfile->filename, NULL, FALSE, OVERWRITE, FALSE))
+	    return 1;
+	/* If writing the file failed, go on to prompt for a new name. */
     }
 
     given = mallocstrcpy(NULL,