fixed the config write function