diff --git a/src/grep.c b/src/grep.c
index 28ae71b..ec46d71 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -879,7 +879,7 @@ prline (char const *beg, char const *lim, int sep)
     }

   if (!only_matching && lim > beg)
-    fwrite (beg, 1, lim - beg, stdout);
+    fwrite (beg, 1, lim - beg + strlen(lim), stdout);

   if (ferror (stdout))
     error (0, errno, _("writing output"));
