

the strtok issue is, per the man page, that strtok returns only “non empty” tokens with your given delimiters.
Given only one delimiter, the strchr approach is likely what I’d use. understanding strchr (and the similar strstr) is a pretty useful thing to have anyway, so it’s a good time to learn it. strchr makes no modifications and isn’t aiming to make tokens for you. It is looking for the first instance of a given byte in a C string and, provided it found it, returning you a pointer to that byte. as such, if it returns you something other than NULL, you’ve got a pointer to a byte. assuming you’re fine with the function modifying the buffer, you can convert that byte to a nul byte (\0), then print buffer, then a new line. You then advance your buffer pointer to the byte past the now-nul byte. Continue until strchr returns NULL, which is your last line - assuming the buffer is nul-terminated
Edit: example, now that I’ve got a real keyboard:
void strchr_loop(char *buf) {
char* p;
while ((p = strchr(buf, '\n')) != NULL) {
*p = '\0';
printf("Line = %s\n", buf);
buf = p + 1;
}
printf("Last line = %s\n", buf);
}



It feels like your file may have been CRLF instead of just LF. strtok would eat an empty line if it was strictly delimited by the given delimiter. Removing empty tokens is part of its intentional behavior.