Read and write config files properly