Writer writer = null;
try {
writer = new FileWriter(new File(statsFile));
writer.write(builder.toString());
} catch (IOException e) {
throw new StatsSaveException("Failed to save stats: " + e.getLocalizedMessage(), e);
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {