import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;


public class Logger {
	private PrintWriter out;

	Logger(String filename) {
		try {
			out = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void append(String line) {
		out.println(line);
		out.flush();
	}
}

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;


public class Logger {
	private String filename;

	Logger(String filename) {
		this.filename = filename;
	}

	public void append(String line) {
		try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)))) {
		    out.println(line);
		}
		catch (IOException e) {
			// fail
		}
	}
}

--- 
+++ 
@@ -5,18 +5,18 @@
 
 
 public class Logger {
-	private String filename;
+	private PrintWriter out;
 
 	Logger(String filename) {
-		this.filename = filename;
+		try {
+			out = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)));
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
 	}
 
 	public void append(String line) {
-		try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)))) {
-		    out.println(line);
-		}
-		catch (IOException e) {
-			// fail
-		}
+		out.println(line);
+		out.flush();
 	}
 }
Fix logger for java 1.6
