Back up configuration when writing to prevent failure loss

The configuration is not always being properly written to the file.
This method will ensure the original user configuration (especially
when manually modified) is not lost in the process.