posted 12 years ago
You're creating a new FileWriter, in append mode, which will add lines to the existing file. But then you're totally ignoring that FW and creating a PrintWriter that doesn't use that FW and instead just goes directly to the file, with no appending. Your second line needs to be
And then, since you're calling pw.close(), you won't need to call fw.flush(). PW's close() will flush and close any wrapped Writers or OutputStreams.