Fixed file writing to config files

Fixed a bug where a configfile that was smaller than the previous file
would have the last bytes of the previous file appended to the new
file.