Fixed a segfault issue writing config file