updated for version 7.2a-017
diff --git a/src/fileio.c b/src/fileio.c
index bbe97c9..d68adec 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -8235,7 +8235,7 @@
      */
     for (buf = firstbuf; buf != NULL; buf = buf->b_next)
     {
-	if (curbuf->b_ml.ml_mfp != NULL)
+	if (buf->b_ml.ml_mfp != NULL)
 	{
 	    /* find a window for this buffer and save some values */
 	    aucmd_prepbuf(&aco, buf);