public static void setINIValue(File file, String key, String value, String section)
            throws FileNotFoundException
    {
        try{
            // Make sure that it is possible to write to the file
            if(!file.canWrite()){
                if(!file.setWritable(true))
                    throw new FileNotFoundException(file.getName() +
                            " is read only.\nThis file must be writable in order for the Profile Manager to work.");
            }
            
            // Read in the game ini
            BufferedReader in = new BufferedReader(
                    new FileReader(file));

            String line, newLine = System.getProperty("line.separator");
            StringBuilder contents = new StringBuilder(1024);

            while( (line = in.readLine()) != null ){
                contents.append(line);
                contents.append(newLine);
            }
            in.close();

            // Find the key's value start location
            int start = contents.indexOf(key);
            
            // Check if the key was found
            if(start == -1){
                // Key not found, add it.
                start = contents.indexOf(section);
                
                String keyValue = key + "=" + value + newLine;
                
                if(start == -1){
                    // Section not found append it.
                    contents.append(newLine);
                    contents.append(section);
                    contents.append(newLine);
                    
                    contents.append(keyValue);
                    
                } else {
                    // Section found, append the line after it
                    start += section.length() + newLine.length();
                    contents.insert(start, keyValue);
                }
                
            } else {
                // Key found, update it
                start += key.length() + 1;

                // Replace the current value with the new value
                contents.replace(start,
                        contents.indexOf(newLine, start),
                        value);
            }

            // Save the file information back to disk
            try{
                BufferedWriter out = new BufferedWriter(new
                        FileWriter(file));

                out.write(contents.toString());

                out.flush();
                out.close();

            } catch(IOException ioe){
                Main.handleException(
                        "An IO Exception has occured while saving the game's INI file to disk.",
                        ioe, Main.WARN_LEVEL);
            }
        } catch(FileNotFoundException fnfe){
            throw new FileNotFoundException(fnfe.getMessage());
        } catch(IOException ioe){
            Main.handleException(
                    "An IO Exception has occured while attempting to read the file '" + file.getName() + "'",
                    ioe, Main.WARN_LEVEL);
        }
    }