Use BufferedWriter to improve the performance.