diff --git a/src/nano.c b/src/nano.c
index 5e4bb0d9db65d40054d98b148877dbbb41136a87..0da1bd5a1302b77bb6bbd8953d0b4aaedd658d56 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1679,6 +1679,9 @@ int do_input(bool allow_funcs)
 	} else
 #endif
 	{
+#ifdef ENABLE_WRAPPING
+	    filestruct *was_next = openfile->current->next;
+#endif
 #ifndef NANO_TINY
 	    filestruct *was_current = openfile->current;
 	    size_t was_x = openfile->current_x;
@@ -1704,7 +1707,7 @@ int do_input(bool allow_funcs)
 #endif
 #ifdef ENABLE_WRAPPING
 	    /* If the cursor moved to another line, clear the prepend flag. */
-	    if (openfile->current != was_current)
+	    if (openfile->current->next != was_next)
 		wrap_reset();
 #endif
 #ifdef ENABLE_COLOR