Fix writing settings to file