When a file is opened and locked by a process, any other process is not allowed to write into it, and in particular to completely overwrite it. But anyone (with the necessary rights) can rename it.
Thus the procedure I usually follow in this case is:
- rename the old file
- copy the new file, with the old name of the existing one
- once the file is unlocked, I delete it
Note that after the step 2, the locking process still operates on the renamed file, but any new process will refers to the new one!