You should always close opend resources explicitly or implicitly with Java 7 try-with-resources
try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {
...
}
besides, there is a more convenient class to write text - java.io.PrintWriter
try (PrintWriter pw = new PrintWriter(file)) {
pw.println("Number of words: " + word);
...
}