Add file locking for reading and writing config files