Split the config.write_in_file method to be more modular and cleaner

Will also allow a remove_in_file or whatever to remove options instead
of blanking them.