public void addRecord(String data) throws Exception {
        Record rec = new Record(data);
        if (isNameExists(rec.name)) {
            remove(rec.name);
            throw new Exception("This name already exists.");
        }
        FileWriter fw = new FileWriter(file, true);
        BufferedWriter bw = new BufferedWriter(fw);
        String lineSeparator = System.getProperty("line.separator");
        String content = rec.name+","+rec.phone+","+rec.address+","+rec.age + lineSeparator;
        bw.write(content);
        bw.close();
    }