diff --git a/nano.c b/nano.c
index fe7b767bc48456c1242ff990bde81c980fcea754..c68ae8aaa2bbaec18505bc856864174397afd353 100644
--- a/nano.c
+++ b/nano.c
@@ -1512,7 +1512,7 @@ int do_wrap(filestruct *inptr)
 	 * between after_break and wrap_line.  If the line already ends
 	 * in a tab or a space, we don't add a space and decrement
 	 * totsize to account for that. */
-	if (newline[strlen(newline) - 1] != '\t' && newline[strlen(newline) - 1] != ' ')
+	if (!isspace(newline[strlen(newline) - 1]))
 	    strcat(newline, " ");
 	else
 	    totsize--;