diff --git a/ChangeLog b/ChangeLog
index 21749e5fcced9fe2d348954932d3593bcc94be94..673e16155aba0dbe2b7da6af717833c1d5231126 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@
 	* doc/man/nanorc.5: Improve ordering of bindable functions.
 	* src/files.c (read_file): Don't open an extra blank buffer when
 	an empty file is read.  Bug was exposed by r5498, December 18.
+	* src/files.c (do_writeout): When the user decides to save the
+	buffer after all, go back to the filename prompt because the
+	buffer may not have a name yet.  This fixes Savannah bug #46752.
 
 2015-12-23  Mike Frysinger  <vapier@gentoo.org>
 	* doc/syntax/autoconf.nanorc: Handle .m4 files too, add the "elif"
diff --git a/src/files.c b/src/files.c
index 61f4d15ca5eaa91c800adcf772b6cbc1f1e0b9b2..590348446ebfe1a5e786c0877762b807485a11de 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2297,9 +2297,8 @@ int do_writeout(bool exiting)
 		if (i == 0) {
 		    free(ans);
 		    return 2;	/* Yes, discard the buffer. */
-		}
-		if (i < 0)
-		   continue;	/* The discard was cancelled. */
+		} else
+		    continue;	/* Go back to the filename prompt. */
 	    }
 
 	    ans = mallocstrcpy(ans, answer);