diff --git a/ChangeLog b/ChangeLog
index 9ca165c8b41146dbf0bbf25c77387374829d9462..9695f63b8b6f823e5b3dcb49e5e663fc2c959c4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,10 @@ CVS code -
 	- For consistency with nano 1.2.x and with other editors, make
 	  the mode of newly created files 666 instead of 600 before
 	  it's modified by the umask. (DLR)
+  do_writeout()
+	- If we're in restricted mode abd the current filename isn't
+	  blank, we can't change it, so disable tab completion in that
+	  case. (DLR)
 - global.c:
   shortcut_init()
 	- Fix erroneous #ifdef so that nano compiles with
diff --git a/src/files.c b/src/files.c
index 9e109329c86fae46f963c14b7a26d648710c576b..90db1d30ede75469ecf341296b591cd8f576d4d6 100644
--- a/src/files.c
+++ b/src/files.c
@@ -1847,7 +1847,11 @@ int do_writeout(int exiting)
 	else
 	    msg = _("File Name to Write");
 
-	i = statusq(TRUE, writefile_list,
+	/* If we're using restricted mode, the filename isn't blank,
+	 * and we're at the "Write File" prompt, disable tab
+	 * completion. */
+	i = statusq(!ISSET(RESTRICTED) || filename[0] == '\0' ? TRUE :
+		FALSE, writefile_list,
 #ifndef NANO_SMALL
 		ans, NULL, "%s%s%s", msg, formatstr, backupstr
 #else
diff --git a/src/nano.c b/src/nano.c
index 3729829301d3fc020c9a769cf435196c8db8dd75..5d8f184b74ebc01a08407829da37752b95001658 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2384,7 +2384,7 @@ void do_justify(int full_justify)
 	 * original to restore it later. */
     int allow_respacing;
 	/* Whether we should change the spacing at the end of a line
-	 * after justifying it.  This should be TRUE whenever we move 
+	 * after justifying it.  This should be TRUE whenever we move
 	 * to the next line after justifying the current line. */
 
     /* We save these global variables to be restored if the user