private void saveSettings()
        {
                LinkedList<String> settingsContents = new LinkedList<String>();
                // Read in the file, replacing the appropriate lines with the new values from the text boxes.  Later on, overwrite the file.
                try {
                        BufferedReader reader = new BufferedReader(new FileReader(SETTINGS_FILE));
                        int counter = 0;
                        String line;
                        while(true)
                        {
                                line = reader.readLine();
                                if(line == null)
                                        break;
                                if(counter == SETTINGS_NICK)
                                        settingsContents.add(nickText.getText());
                                else if(counter == SETTINGS_CHAN)
                                        settingsContents.add(chanText.getText());
                                else if(counter == SETTINGS_PASS)
                                        settingsContents.add(passText.getText());
                                else if(counter == SETTINGS_SERVER)
                                        settingsContents.add(serverText.getText());
                                else
                                        settingsContents.add(line);
                                counter++;
                        }
                        reader.close();
                } catch(IOException e) {
                        e.printStackTrace();
                }
                
                // Get the last element in settings and save it separately so that we don't leave a trailing newLine.
                // We assume that there's at least one line in the settings file, otherwise the program would have terminated before.
                String lastElem = settingsContents.removeLast();
                
                try {
                        BufferedWriter writer = new BufferedWriter(new FileWriter(SETTINGS_FILE));
                        for(String s : settingsContents)
                        {
                                writer.write(s);
                                writer.flush();
                                writer.newLine();
                                writer.flush();
                        }
                        writer.write(lastElem);
                        writer.flush();
                        
                        writer.close();
                } catch(IOException e) {
                        e.printStackTrace();
                }
        }