fix config file reading and writing