title: Add whitespace after every word in file (Java)
body: <p>I want to add a space after every word in a file
  E.G thisisatest becomes this is a test</p>
  
  <p>I was able to make it add a space at the end of the file using .write</p>
  
  <p>This is the code I used to add spaces</p>
  
  <pre><code>try {
      String filename = "test.txt";
      FileWriter fw = new FileWriter(filename,true);
      fw.write(" ");
      fw.close();
  } catch(IOException ioe)
    {
        System.err.println("IOException: " + ioe.getMessage());
    }
  </code></pre>
  
  <p>This is the code I used to find the words</p>
  
  <pre><code> try {
       File file = new File(WORD_FILE);
       Scanner scanner = new Scanner(file);
       while (scanner.hasNextLine()) {
           String line = scanner.nextLine();
           for(String word : line.split("\\s")) {
              if (!word.isEmpty())
                  System.out.println(word);
            }
        }
        scanner.close();
     } catch (FileNotFoundException e) {
          System.out.println("File not found.");
     }
  </code></pre>
  
  <p>It added a blank space at the end of the file but what I wanted it to do was add a space after every word</p>