diff --git a/ChangeLog b/ChangeLog
index c3c75d9a2bbf9b483c24ba0d318512b155ad8ade..a05622bf27c3aa195701df60431c36ea2e5c03ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -80,12 +80,12 @@ CVS code -
 	- Add support for reading in UTF-8 sequences to the low-level
 	  input routines.  Changes to get_kbinput() and
 	  get_translated_kbinput(). (DLR)
-	- Reduce search_last_line to a local variable in findnextstr(),
-	  since it's always set to FALSE just before and after
-	  findnextstr() is called and isn't used anywhere except in
-	  findnextstr().  Changes to do_int_spell_fix(), findnextstr(),
-	  do_search(), do_research(), do_replace(), and
-	  do_find_bracket(). (DLR)
+	- Reduce search_last_line to a static variable in search.c, and
+	  allow it to be set to FALSE via a function.  New function
+	  findnextstr_wrap_reset(); changes to do_int_spell_fix(),
+	  findnextstr(), do_search(), do_research(), do_replace_loop(),
+	  do_replace(), and do_find_bracket(). (DLR, problem with making
+	  search_last_line local to findnextstr() found by Rocco)
 	- When saving or changing file positions, be sure not to ignore
 	  placewewant.  Changes to do_int_spell_fix(), findnextstr(),
 	  do_replace_loop(), and do_replace(). (DLR)
diff --git a/src/nano.c b/src/nano.c
index 31e558a0ecccda5a1a76d12cd7b85aec83f76d03..da9c192dc1a3013f9a62fa844cf3a3d0a8416092 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1471,6 +1471,7 @@ bool do_int_spell_fix(const char *word)
     placewewant = 0;
 
     /* Find the first whole-word occurrence of word. */
+    findnextstr_wrap_reset();
     while (findnextstr(TRUE, TRUE, FALSE, fileage, 0, word, NULL)) {
 	if (is_whole_word(current_x, current->data, word)) {
 	    edit_refresh();
diff --git a/src/proto.h b/src/proto.h
index b290673a7943f2f07dd8f3c5ca82d515d9cb5b4b..bf8a7e190a4002d7843d7390ea838949c169f0a1 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -408,6 +408,7 @@ bool is_whole_word(int curr_pos, const char *datastr, const char
 bool findnextstr(bool can_display_wrap, bool wholeword, bool
 	no_sameline, const filestruct *begin, size_t beginx, const char
 	*needle, size_t *needle_len);
+void findnextstr_wrap_reset(void);
 void do_search(void);
 #ifndef NANO_SMALL
 void do_research(void);
diff --git a/src/search.c b/src/search.c
index 6e8d268efdd34f0739facf7933fa7b69c79d00c8..7cea9f2b5fc0d23a04a88e3e53dd50223b6adbc0 100644
--- a/src/search.c
+++ b/src/search.c
@@ -31,6 +31,8 @@
 #include "proto.h"
 #include "nano.h"
 
+static bool search_last_line = FALSE;
+	/* Have we gone past the last line while searching? */
 #ifdef HAVE_REGEX_H
 static bool regexp_compiled = FALSE;
 	/* Have we compiled any regular expressions? */
@@ -281,8 +283,6 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
     size_t current_x_find = 0;
 	/* The location of the match we found. */
     int current_y_find = current_y;
-    bool search_last_line = FALSE;
-	/* Have we gone past the last line while searching? */
 
     /* rev_start might end up 1 character before the start or after the
      * end of the line.  This won't be a problem because strstrwrapper()
@@ -415,6 +415,11 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
     return TRUE;
 }
 
+void findnextstr_wrap_reset(void)
+{
+    search_last_line = FALSE;
+}
+
 /* Search for a string. */
 void do_search(void)
 {
@@ -455,6 +460,7 @@ void do_search(void)
 	update_history(&search_history, answer);
 #endif
 
+    findnextstr_wrap_reset();
     didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
 	answer, NULL);
 
@@ -508,6 +514,7 @@ void do_research(void)
 	    return;
 #endif
 
+	findnextstr_wrap_reset();
 	didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
 		last_search, NULL);
 
@@ -672,6 +679,7 @@ ssize_t do_replace_loop(const char *needle, filestruct *real_current,
     if (canceled != NULL)
 	*canceled = FALSE;
 
+    findnextstr_wrap_reset();
     while (findnextstr(TRUE, wholewords,
 #ifdef HAVE_REGEX_H
 	/* We should find a bol and/or eol regex only once per line.  If
@@ -1030,6 +1038,7 @@ void do_find_bracket(void)
     /* We constructed regexp_pat to be a valid expression. */
     assert(regexp_compiled);
 
+    findnextstr_wrap_reset();
     while (TRUE) {
 	if (findnextstr(FALSE, FALSE, FALSE, current, current_x,
 		regexp_pat, NULL)) {