Fixed problems with writing config file