title: BufferedWriter not producing output to File
body: <p>In my code I have to take every other word starting with the second word and reverse it. The other classes/threads are doing their job fine. I can print the output to the console window and it prints correctly. However, whenever i try to write to a text file I have on my desktop it does not produce any output.</p>
  
  <p>My code:</p>
  
  <pre><code>package ProducerConsumerAssignment;
  
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  
  import java.util.concurrent.BlockingQueue;
  
  /**
   *
   * @author Tyler Weaver
   */
  public class WordWriter implements Runnable {
  
      private final String END_FLAG = "Terminate the queue";
      private static BlockingQueue&lt;CharSequence&gt; in;
      private final File output;
  
      /**
       * Constructs a WordWriter object
       *
       * @param file the file to write words to
       * @param queue the blocking queue to retrieve words from
       */
      public WordWriter(final File file, BlockingQueue queue) {
          output = file;
          in = queue;
      }
  
      /**
       * Executes when being called in a thread
       */
      @Override
      public void run() {
          boolean isInterrupted = false;
  
          while (!isInterrupted) {
              try (BufferedWriter out = new BufferedWriter(new FileWriter(output))) {
                  CharSequence word = in.take();
  
                  if (word.toString().equalsIgnoreCase(END_FLAG))
                      Thread.currentThread().interrupt();
  
                  out.write(word.toString() + " ");
                  System.out.printf("%s%n", word);
              } catch (IOException ex) {
                  System.err.printf("Error closing the file!%n%s%n", ex);
              } catch (InterruptedException ex) {
                  isInterrupted = true;
              }
          }
      }
  }
  </code></pre>