diff --git a/src/text.c b/src/text.c
index e7a03fbd4bd900eeb9117bfc9cedfc4a421b1444..c03f3d2b3580a8f4516f0e9a072100a0a3b6a4f7 100644
--- a/src/text.c
+++ b/src/text.c
@@ -3044,6 +3044,11 @@ const char *do_alt_speller(char *tempfile_name)
 #ifndef NANO_TINY
     if (old_mark_set) {
 	filestruct *top_save = openfile->fileage;
+
+	/* If a magicline was added, remove it again. */
+	if (added_magicline)
+	    remove_magicline();
+
 	/* Adjust the end point of the marked region for any change in
 	 * length of the region's last line. */
 	if (right_side_up)
@@ -3051,10 +3056,6 @@ const char *do_alt_speller(char *tempfile_name)
 	else
 	    openfile->mark_begin_x = strlen(openfile->filebot->data);
 
-	/* If a magicline was added, remove it again. */
-	if (added_magicline)
-	    remove_magicline();
-
 	/* Unpartition the filestruct so that it contains all the text
 	 * again.  Note that we've replaced the marked text originally
 	 * in the partition with the spell-checked marked text in the