add mutex when write file