diff --git a/src/utils.c b/src/utils.c
index 4c52d1d3999c28a2d2c432c972d7d0d81133493c..738d576f5c3f0c6ec0eca5839a7ec42c43b848e5 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -290,6 +290,7 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream)
 
     /* Null terminate the buffer. */
     null_at(lineptr, indx++);
+    *n = indx;
 
     /* The last line may not have the delimiter, we have to return what
      * we got and the error will be seen on the next iteration. */