Add file lock to write one xml file at a time