title: Appending text files using buffered type writer java
body: <p>I'm trying to store data that is being inputted by a user and store it in a text file to be manipulated later on, I'm having problems with it keep on overwriting the first lines on data code below:</p>
  
  <pre><code>public void AddDataToFile(int i)
  
  {
      BufferedWriter writer = null;
      try {
  
          writer = new BufferedWriter(new FileWriter("./Cat Info.txt"));
  
          Cat catCurrent;
          catCurrent = catPenArray [i];            
          writer.append("Pen Number " + (i + 1));
          writer.newLine();
          writer.write("Cat Name " + catCurrent.CatName);
          writer.newLine();
          writer.write("Cat Gender " + catCurrent.Gender);
          writer.newLine();
          writer.write("Chip Number " + catCurrent.ChipNumber);
          writer.newLine();
          writer.write("Arival Date " + catCurrent.ArrivalDate);
          writer.newLine();
          writer.write("Departure Date " + catCurrent.DepartureDate);
          writer.newLine();
          writer.write("How often fed " + catCurrent.HowOftenFed);
          writer.newLine();
          writer.write("Type Of food " + catCurrent.Food);
          writer.newLine();
      } catch (IOException e) {
          System.err.println(e);
      } finally {
          if (writer != null) {
              try {
                  writer.close();
              } catch (IOException e) {
                  System.err.println(e);
              }
          }
      }
  } 
  </code></pre>