diff --git a/ChangeLog b/ChangeLog
index 1a3913aa673ed12375891a8d45017b33683e7719..d4864319ed5c091d5b6709c5f13a075a5b97d422 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
 	that is: treat the deletion of words like pressing Backspace/Delete.
 	* src/search.c (get_history_completion, find_history): Cycle through
 	the items from newest to oldest.  This fixes Savannah bug #47205.
+	* src/files.c (do_writeout): When the name of the file was changed,
+	always ask whether this is okay.  This fixes Savannah bug #46894.
 
 2016-03-19  Benno Schulenberg  <bensberg@justemail.net>
 	* src/search.c (search_init): Always remember the last typed string,
diff --git a/src/files.c b/src/files.c
index 23ee8806ece0c182753fe695bf80841f909184ba..991050b088c84464eacd2837b960c93ac3b38bdc 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2276,6 +2276,8 @@ int do_writeout(bool exiting)
 #ifndef DISABLE_EXTRA
     static bool did_credits = FALSE;
 #endif
+    bool maychange = FALSE;
+	/* Whether it's okay to save the file under a different name. */
     bool result = FALSE;
 
     if (exiting && openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
@@ -2452,19 +2454,29 @@ int do_writeout(bool exiting)
 		    if (ISSET(RESTRICTED))
 			continue;
 
-		    if (name_exists) {
-			i = do_yesno_prompt(FALSE,
-				_("File exists; OVERWRITE? "));
-			if (i == 0 || i == -1)
-			    continue;
-		    } else
+		    if (!maychange) {
 #ifndef NANO_TINY
-		    if (exiting || !openfile->mark_set)
-#endif
-		    {
-			i = do_yesno_prompt(FALSE,
-				_("Save file under DIFFERENT NAME? "));
-			if (i == 0 || i == -1)
+			if (exiting || !openfile->mark_set)
+#endif
+			{
+			    i = do_yesno_prompt(FALSE,
+					_("Save file under DIFFERENT NAME? "));
+			    if (i < 1)
+				continue;
+			    maychange = TRUE;
+			}
+		    }
+
+		    if (name_exists) {
+			char *question = _("File \"%s\" exists; OVERWRITE? ");
+			char *message = charalloc(strlen(question) +
+						strlen(answer) + 1);
+			sprintf(message, question, answer);
+
+			i = do_yesno_prompt(FALSE, message);
+			free(message);
+
+			if (i < 1)
 			    continue;
 		    }
 		}