Do you mean that you can't change the source of the file when switching between outputting to the console and outputting to a file?
Or do you mean that it's forbidden to change the file under any circumstances?
If it's the second of these, I can't help you.
If it's the first, then place this just after each printf()
That won't hurt anything when outputting to the console, and might help when outputting to the file.
Another thing to try: Run a "Hello, world!" program under the same situation, and see whether it outputs to the temp file. If it doesn't, we all have a serious problem. (grin) If it does, make a temporary version of your program and make it more and more like the "Hello, world!" program until it output something.
Hope this helps.