Set the buffering mode on the file stream.
setbuf(logFile, NULL);
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setbuf?view=msvc-170
Updated: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setvbuf?view=msvc-170