Implemented previous version using a single FileWriter and BufferedWriter