Maybe you want to use "lsof" on linux to find out what is blocking your file.
On Windows you maybe want to use a sysinternals (now Microsoft) tool to see which files are open by which process,
I leave it to you to find the appropriate tool ...
Your node was hard to read. Perhaps you could give a "formatted" sample code where people could see how you accomplish the opening e.g.