diff --git a/ChangeLog b/ChangeLog
index 1faf57327f92253e63c1e357d0d5a7200c78804b..c8a0bdb5bbc0f3c2c6274ace2f6df9942faf0863 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 CVS code -
 - General:
 	- Miscellaneous comment fixes. (DLR)
+- files.c:
+  do_writeout()
+	- For consistency, when saving a file with no name, don't
+	  allow overwriting an existing file when in restricted
+	  mode. (DLR)
 
 GNU nano 2.0.0 - 2006.11.06
 - General:
diff --git a/src/files.c b/src/files.c
index 6aec143ce29adba2db52d092311a11a445bdc131..abd3dc6b0812f50e34bc6c5744d8b9e886af3bd5 100644
--- a/src/files.c
+++ b/src/files.c
@@ -1874,10 +1874,22 @@ int do_writeout(bool exiting)
 		struct stat st;
 
 		if (stat(answer, &st) != -1) {
-		    i = do_yesno_prompt(FALSE,
-			_("File exists, OVERWRITE ? "));
-		    if (i == 0 || i == -1)
-			continue;
+		    /* If we're using restricted mode, we aren't allowed
+		     * to save a new file under the name of an existing
+		     * file.  In this case, show a "File exists"
+		     * error. */
+		    if (!ISSET(RESTRICTED)) {
+			i = do_yesno_prompt(FALSE,
+				_("File exists, OVERWRITE ? "));
+			if (i == 0 || i == -1)
+			    continue;
+		    } else {
+			errno = EEXIST;
+			statusbar(_("Error writing %s: %s"), answer,
+				strerror(errno));
+			retval = -1;
+			break;
+		    }
 		/* If we're using restricted mode, we aren't allowed to
 		 * change the name of a file once it has one, because
 		 * that would allow reading from or writing to files not