title: ArrayList overwriting only and not adding data
body: <p>i want to create a 'Add Account' Application. I've created a ArrayList and store it to a textfile, however, it only write one set of data to textfile.</p>
  
  <p>Ex: Account Name: Joe
      Account Number: 10
  When i press, 'Save' button, it's now saved in the textfile, but when i create a new accont, for example: Account Name: Ryan, Account Number: 20, the first account that i've create has been overwrited. Could you please advise what is wrong on my code?</p>
  
  <pre><code>public class JFrameNewAccount extends javax.swing.JFrame {
      ArrayList&lt;String&gt; al = new ArrayList&lt;String&gt;();
  
      private void btnSaveAActionPerformed(java.awt.event.ActionEvent evt) {
          ButtonGroup bg = new ButtonGroup();
          bg.add(rad_savings);
          bg.add(rad_checking);
          al.add(txt_accountnumber.getText());
          al.add((txt_accountname.getText()));
          if (rad_savings.isSelected()) {
              al.add(rad_savings.getText());
          } else {
              al.add(rad_checking.getText());
              al.add(txt_initialbalance.getText());
              if (rad_savings.isSelected()) {
                  al.add(txt_interestrate.getText());
              } else {
                  al.add(txt_overdraft.getText());
              }
              String fileName = "bank.txt";
              FileWriter file = null;
              try {
                  file = new FileWriter(fileName);
                  PrintWriter pw = new PrintWriter(file);
                  for (String str : al) {
                      pw.println(str);
                  }
                  pw.flush();
                  System.out.println("Write successful...");
              } catch (FileNotFoundException ex) {
                  System.out.println("File not found....");
              } catch (IOException ex) {
                  Logger.getLogger(JFrameNewAccount.class.getName()).log(
                          Level.SEVERE, null, ex);
              } finally {
                  try {
                      file.close();
                  } catch (IOException ex) {
                      Logger.getLogger(JFrameNewAccount.class.getName()).log(
                              Level.SEVERE, null, ex);
                  }
              }
              JOptionPane
                      .showMessageDialog(this, "Your accont has been created!");
              txt_accountname.setText("");
              txt_accountnumber.setText("");
              txt_initialbalance.setText("");
              txt_overdraft.setText("");
              txt_interestrate.setText("");
              bg.clearSelection();
              txt_accountnumber.requestFocus();
          }
      }
  }            
  </code></pre>