diff --git a/ChangeLog b/ChangeLog
index a23ff7a6c3cbf3bcc82f27626c9a1e7407cceca8..37da3e4c93fc1f4d81e62cd43aabba0e8d9749a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 2016-02-07  Benno Schulenberg  <bensberg@justemail.net>
 	* src/files.c (update_poshistory): Don't put files in the history list
 	when they have the default cursor position (line 1, column 1).
+	* src/files.c (write_file): Avoid a pointless lstat() when not writing
+	to a temp file, and in the bargain elide two variables.
 
 2016-02-06  Benno Schulenberg  <bensberg@justemail.net>
 	* src/files.c (write_file): Remove the --nofollow option that hasn't
diff --git a/src/files.c b/src/files.c
index 8895bc9f402d705e5814cdb2d4ca3578b3d624d2..65756976a407b7d60072233ec09ca55265fdcbd7 100644
--- a/src/files.c
+++ b/src/files.c
@@ -1760,14 +1760,9 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
 	/* The result of stat().  TRUE if the file exists, FALSE
 	 * otherwise.  If name is a link that points nowhere, realexists
 	 * is FALSE. */
+#endif
     struct stat st;
 	/* The status fields filled in by stat(). */
-#endif
-    bool anyexists;
-	/* The result of lstat().  The same as realexists, unless name
-	 * is a link. */
-    struct stat lst;
-	/* The status fields filled in by lstat(). */
     char *realname;
 	/* name after tilde expansion. */
     FILE *f = NULL;
@@ -1797,10 +1792,8 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
     }
 #endif
 
-    anyexists = (lstat(realname, &lst) != -1);
-
     /* If the temp file exists and isn't already open, give up. */
-    if (tmp && anyexists && f_open == NULL)
+    if (tmp && (lstat(realname, &st) != -1) && f_open == NULL)
 	goto cleanup_and_exit;
 
 #ifndef NANO_TINY