Debugging MFC program calling C DLL using fprintf
===

I have an MFC program which calls a C dll that crashes in release, but not in debug.  I have tried using fprintf to write messages to a file, and this works for the first pass through the program.  However, the program crashes the second time the program runs a calculation.  

I close the debug log file immediately after writing to it as the first executable statements at the top of the C routine.  Info is written to the log file after the first calculation, but not during the 2nd calculation.

Any suggestions?

Mike