I think you are going to get intermixed messages unless you are very careful. If you use fprintf(), as with the existing code, but skip the fflush() call after each fprintf, you risk getting intermixed messages when fprintf itself issues a write when its stdio buffer fills.
If you could peek inside the stdio buffering, you could check how full the buffer is getting and issue your own fflush() at a record boundary. But that's not portable. Instead, you could use setvbuf() to control the size of the buffer and accumulate the results of the fprintf() calls to keep track of how many bytes have been used. Again, call fflush() at a record boundary when your accumulator gets above xx% of the size of your buffer. Your counter will get out of sync with reality if the process forks (because fork flushes stdio buffers), but that just means you'll do your own flush earlier than you needed to. Then, you'll be back in sync.