updated for version 7.0161
diff --git a/src/fileio.c b/src/fileio.c
index a3ceb4b..302e93a 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3150,8 +3150,10 @@
 			    || st.st_mode != perm)
 			backup_copy = TRUE;
 # endif
-		    mch_remove(IObuff);
+		    /* Close the file before removing it, on MS-Windows we
+		     * can't delete an open file. */
 		    close(fd);
+		    mch_remove(IObuff);
 		}
 	    }
 	}