private void writeHistoryFile() {

		File historyFile = getHistoryFile();
		try {
			File tmpFile = new File(historyFile.getParentFile(), historyFile.getName() + ".new");
			tmpFile.delete();

			BufferedWriter out = new BufferedWriter(new FileWriter(tmpFile));
			for (int i = 0; i < versions.length; i++) {
				out.write(encodeVersion(versions[i]));
				out.newLine();
			}
			out.close();

			// Rename files
			File oldFile = null;
			if (historyFile.exists()) {
				oldFile = new File(historyFile.getParentFile(), historyFile.getName() + ".bak");
				oldFile.delete();
				if (!historyFile.renameTo(oldFile)) {
					throw new IOException("file is in use");
				}
			}
			if (!tmpFile.renameTo(historyFile)) {
				if (oldFile != null) {
					oldFile.renameTo(historyFile);
				}
				throw new IOException("file error - backup may exist");
			}
			if (oldFile != null) {
				oldFile.delete();
			}
		}
		catch (IOException e) {
			item.log("ERROR! failed to update history file: " + e.toString(), null);
		}
	}
Write all history data to file.
Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/HistoryManager.java