Replacing bufferedwriter with printwriter