Sorry for the confusing title. I tried to make it as concise as possible. I am reading from an input file, parsing it, and writing to an output file. The problem I am having is once the program finishes running, the output file only contains the last item that is read from the input. Each input is being overwritten by the next. I think my problem lies in this code segment.
 protected void processLine(String aLine) throws IOException {
   Scanner scanner = new Scanner(aLine);
   scanner.useDelimiter(" ");
   if (scanner.hasNext()){
     String input = scanner.next();
     PrintWriter writer = new PrintWriter(new FileWriter("output.txt"));
     writer.println(input);
     writer.close();     
    } else {
        System.out.println("Empty or invalid line. Unable to process.");
      }
   }
Any and all help/advice is appreciated.
 
     
    