Trying to create a text file log using java
<p>I'm new to programming and trying to create a log file. The code I have written works at sending the message and the time to a text file . But every time I send another message it just records over the previous. I want to have a list of messages and times just not the latest one.</p>

<pre><code>public void run () {
        String message;
        try {
            while ((message = reader.readLine()) != null){
                System.out.println( "You voted " + message + " You the best") ;
                BufferedWriter out = new BufferedWriter(new FileWriter("test.txt"));
                out.append(message + "\n");
                TimeZone tz = TimeZone.getTimeZone("UTC"); // or PST, MID, etc ...
                Date now = new Date();
                DateFormat df = new SimpleDateFormat ("           yyyy.MM.dd hh:mm:ss ");
                df.setTimeZone(tz);
                String currentTime = df.format(now);
                String timeStamp = new SimpleDateFormat().format( new Date() ); 

                FileWriter aWriter = new FileWriter("test.txt", true);
                aWriter.write(currentTime + "   "  + "\n");
                aWriter.flush();
                aWriter.close();

                out.write(message);
                out.close();
                everyoneMessage(message);

            } // close while
            }catch(Exception ex) {ex .printStackTrace();}
        } // close run
    }// close inner class
</code></pre>
