What you need is a THIRD file. You should never lock the file(s) you're processing, as this leads to all sorts of problems in most situations.
I was worried someone would say that, although, having thought about it, I think the 2 file consecutive locking is (nearly) as good (as far as my processing goes).
Check the files.
Easier said than done, I think, but I'm sure something will be available.