private void writeFieldsToFile(HashMap <String,String> fields) {

		// What is the write method going to do
		// Well, it can read the old file
		// Replace / Add valuues to it
		// And then re-write it
		// Let's save it as plain-text for now, maybe look at zipping it after 
		
		// Firstly, read the old values and replace them with any new ones
		// Or add new ones if they don't exist
		Set<String> newKeys = fields.keySet();
		
		HashMap<String,String> oldValues = readFielldsFromFile();
		
		for (String key : newKeys) {
			if (oldValues.containsKey(key)) {
				// Remove it for replacement
				oldValues.remove(key);
			}
			
			oldValues.put(key, fields.get(key));
		}
		
		// Put this into a string and save it
		StringBuffer file = new StringBuffer();
		for (String key : oldValues.keySet()) {
			file.append(key+LINE_SPLITTER+oldValues.get(key)+"\r\n");
		}
		
		String stateFile = MDFConfig.getStateFile();
		
		FileOutputStream fout = null;
		
		try {
			File f = new File(stateFile);
			
			if (f.exists()) {
				f.delete();
			}
			
			fout = new FileOutputStream(f);
			
			fout.write(file.toString().getBytes());
			
		} catch (Exception e) {
			log.log(Level.WARNING,"An error occurred writing the state file " + e.getMessage(),e);
		} finally {
			if (fout != null) {
				try {fout.close();} catch (Exception e) {}
			}
		}
	}