title: FileWriter not appending to existing file
body: <p>I am writing a method that takes in a <code>List</code> of Twitter <code>Status</code> objects as a parameter, opens a log file containing <code>String</code> represenatations of Tweets, checks if any of the <code>String</code> representations of the <code>Status</code> objects are already written to the file - if so, it removes them from the list, if not it appends the <code>Status</code> to the file.</p>
  
  <p>Everything is working up until I attempt to write to the file. Nothing is being written at all. I am led to believe that it is due to the method having the file open in two different places: <code>new File("tweets.txt")</code> and <code>new FileWriter("tweets.txt, true)</code>.</p>
  
  <p>Here is my method:</p>
  
  <pre><code>    private List&lt;Status&gt; removeDuplicates(List&lt;Status&gt; mentions) {
          File mentionsFile = new File("tweets.txt");
          try {
              mentionsFile.createNewFile();
          } catch (IOException e1) {
              // Print error + stacktrace
          }
  
          List&lt;String&gt; fileLines = new ArrayList&lt;&gt;(); 
          try {
              Scanner scanner = new Scanner(mentionsFile);
              while (scanner.hasNextLine()) {
                  fileLines.add(scanner.nextLine());
              }
              scanner.close();
          } catch (FileNotFoundException e) {
              // Print error + stacktrace
          }
  
          List&lt;Status&gt; duplicates = new ArrayList&lt;&gt;();    
          for (Status mention : mentions) {
              String mentionString = "@" + mention.getUser().getScreenName() + " \"" + mention.getText() + "\" (" + mention.getCreatedAt() + "\")";
              if (fileLines.contains(mentionString)) {
                  duplicates.add(mention);
              } else {
                  try {
                      Writer writer = new BufferedWriter(new FileWriter("tweets.txt", true));
                      writer.write(mentionString);
                  } catch (IOException e) {
                      // Print error + stacktrace
                  }
  
              }
          }
  
          mentions.removeAll(duplicates);
          return mentions;
      }
  </code></pre>