diff --git a/search.c b/search.c
index 80b0a4a7d9de402e99c3eb72316b531eec549c76..df2f53aa439a49ac84bef8b09a3dd49b4430ae8d 100644
--- a/search.c
+++ b/search.c
@@ -453,7 +453,8 @@ int do_search(void)
 
 #ifndef NANO_SMALL
     /* add this search string to the search history list */
-    update_history(&search_history, answer);
+    if (strcmp(answer, ""))
+	update_history(&search_history, answer);
 #endif	/* !NANO_SMALL */
 
     search_last_line = 0;
@@ -739,7 +740,8 @@ int do_replace(void)
     }
 
 #ifndef NANO_SMALL
-    update_history(&search_history, answer);
+    if (strcmp(answer, ""))
+	update_history(&search_history, answer);
 #endif	/* !NANO_SMALL */
 
     /* Again, there was a previous string, but they deleted it and hit enter */
@@ -788,7 +790,7 @@ int do_replace(void)
 		_("Replace with"));
    }
 #ifndef NANO_SMALL
-    if (i == 0)
+    if (i == 0 && strcmp(answer, ""))
 	update_history(&replace_history, answer);
 #endif	/* !NANO_SMALL */