Add write_config method.