I don't really see the problem---why don't you leave the file open for writing? The FS won't close it on its own, after all: it will wait patiently for you to close it.
The fragmentation is nearly unavoidable. Perhaps you can counter it to some extent by reserving space in the form of a really big file, sufficiently sized to contain the complete log, and then gradually overwrite it, making sure you pad the stuff you write out to the exact same size as the original dummy file. But that is a wild guess at best, relying on inner workings of the FS you should really not be relying on. Why is a non-fragmented file so important anyway? The FS will handle the fragmentation transparently when you read the file back into memory.
Methinks you are trying to solve a problem which really is not a problem :-).