public static void writeFile(Preferences pref, File f, String content, boolean isBackup) {
		String fName = f.getAbsolutePath();
		if (f.exists()) {
			if (!isBackup) {
				writeLog("File '"
						+ f
						+ "' already exists - not overwriting due to config option");
				return;
			}
			
			File backup = new File(fName + ".bak");
			if (backup.exists()) {
				if (backup.delete())
					writeLog("Backup file " + backup
							+ " exists and was deleted");
				else {
					writeLog("Error deleting backup file " + backup);
					return ;
				}
			}

			File renameIt = new File(fName);
			if (renameIt.renameTo(backup)) {
				writeLog("File " + f + " is being backed up to "
						+ backup);
			} else {
				writeLog("Error backing up file " + f);
				writeLog("No Backup exists for the file - be careful");
				return ;
			}
		}
		if (f.exists()) {
			writeLog("File " + f +" still exist, writing failed!");
			return;
		}
		BufferedReader in = null;
		BufferedWriter out = null;
		try {
			out = new BufferedWriter(new FileWriter(f));
			in = new BufferedReader(new StringReader(content));
			while (true) {
				String line = in.readLine();
				if (line == null)
					break;
				out.write(line);
				out.write(Utilities.lineEnding);
			}
			writeLog("Successfully written to " + f);
			in.close();
			out.flush();
			out.close();
		} catch (IOException e) {
			writeLog("Failed written to" + f + ": " + e.toString());
		}
	}