I do run the two scripts back to back in the order shown so I can see the benefit of having a brief pause between the two, as you suggest. However, I don't think that is the real problem.
You see, BOTH scripts encounter that error (sometimes). Something is locking the file and it isn't just a...