class ConfigFileUpdaterWriter {

    public void updateAndWrite(
        List<KeyData> newKeys, KeyVaultConfig keyVaultConfig, Config config, Path configDest)
            throws IOException {
        LOGGER.info("Writing updated config to {}", configDest);

        update(newKeys, keyVaultConfig, config);

        try (OutputStream out = filesDelegate.newOutputStream(configDest, CREATE_NEW)) {
            JaxbUtil.marshal(config, out);
            LOGGER.info("Updated config written to {}", configDest);
        } catch (Exception e) {
            LOGGER.info("Writing updated config failed, cleaning up: deleting {}", configDest);
            filesDelegate.deleteIfExists(configDest);

            throw e;
        }
    }

    public  ConfigFileUpdaterWriter(FilesDelegate filesDelegate);

}