updated for version 7.0-181
diff --git a/src/fileio.c b/src/fileio.c
index abbe1e7..2108bb8 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6178,8 +6178,8 @@
     if (retval != FAIL)
     {
 	curbuf = frombuf;
-	while (!bufempty())
-	    if (ml_delete(curbuf->b_ml.ml_line_count, FALSE) == FAIL)
+	for (lnum = curbuf->b_ml.ml_line_count; lnum > 0; --lnum)
+	    if (ml_delete(lnum, FALSE) == FAIL)
 	    {
 		/* Oops!  We could try putting back the saved lines, but that
 		 * might fail again... */