change System.out to writer