in reply to Re^2: file used by process
in thread file used by process

Which is why I said "or it is locked (maybe depending on the OS)" - it's an OS dependent behaviour. It's also why I went on to suggest you could use flock, although others have pointed out that that may not do quite what you want either.

True laziness is hard work