Fix bug when writing config to hash

Previously it could possibly write some empty keys.