Are you trying to read the file while the tool has it open for writing?
Unless you specify sharing semantics when opening the file, you're going to get exclusive access by default. So if the tool opens the text file without specifying sharing, you're not going to be able to read it from your application while the tool has it open.
You should be using CreateFile(), not OpenFile(), which is for compatability with 16 bit Windows apps, and specify sharing semantics in the call.
Could it be that when you're in debug mode, it takes long enough that the tool manages to complete and terminates, so that you're then able to open it with exclusive access? Or, you're delaying enough that file buffers in the tool are eventually flushed out to disk. Disk i/o likes to work in chunks of data related to the sector size on the disk (cluster size in Windows) so if the tool does lots of small writes to the file, this could be getting postponed, as it's not efficient to go to the disk each time. It's called lazy flushing, and Windows OS's do this.
The tool could use FlushFileBuffers() function to force the data to be written out to disk - maybe it does or maybe it doesn't - do you have the source code for the tool? If the standard C library is being used for file i/o in the tool, there's a way to flush buffers there too. But whoever authored the tool may not have provided for the way you're trying to use the file. If that's the case, there's not much you can do about it I think other than wait for the tool to eventually write out to disk.
Do you have some other common resource in use by both your code and the tool? Maybe they're contending over something other than the file, and the tool is getting suspended and not writing to disk. In debug mode, I imagine your application thread gets suspended when you're single stepping or at a breakpoint - this would allow the tool to run freely if there's resource contention of some kind.
Menchar