title: BlueJ: My code compiles with no errors but the program won't run
body: <p>For my computing gcse, i have to write code which takes a text file, i used JFK's moon speech and pasted it into a word file five times, and the code has to do a few things; -Rewrite the speech with no duplicates -Rewrite the speech but in digits. each word in the speech (excluding duplicates) are given a number which corresponds with the position of the word in the speech When compiling the code im getting no syntax errors but when i run the program the program displays: "Error Occurred Error occured when writing file" i have no clue on how to fix this so if anyone could take a look at my code and suggest how to fix it that'd be a great help.
  <a href="http://pastebin.com/3avu4ni3" rel="nofollow noreferrer">http://pastebin.com/3avu4ni3</a></p>