added error check for config file write