It doesn't matter if nothing else in your app is accessing the file. If anything holds an open handle on the file then your app will fail to open it. A text editor, log viewer, indexing service maybe... It's outside of your control.
There are other reasons why this might be failing as well. For starters, you aren't specifying a location for the file. Either you're setting the CWD explicitly elsewhere, or you're relying on it being a location you can actually write to... Check both of these assumptions.