Fixed bug with BufferedWriter