The script takes about 2 second to update the file. Is there a way to check (for locking) the file before opening it?