Yes, by the given code the file is always reset, because the FileWriter
constructor you use. You shoud change your code like this::
..... .... new FileWriter( filename + "a", true);
This will append the file, i.e, open and position the file pointer at the next
free line available.
You should also consult Java Documentation for help in constructors and IO
functions, or, you can better use an IDE like SUNONE Studio for auto code
completion and hints.