Reading file's content and writing to console
<p>I have a program which reads contents from a file and prints it on the screen. But program prints every other line i.e., skips every other line.
package InputOutput;</p>

<pre><code>import java.io.*;

public class CharacterFileReaderAndFileWriter{

    private BufferedReader br = null;

    private PrintWriter pw = new PrintWriter(System.out, true);


    /* Read from file and print to console */
    public void readFromFile() throws IOException{

        try{
            br = new BufferedReader(new FileReader("E:\\Programming\\Class files\\practice\\src\\InputOutput\\test.txt"));
        }
        catch(FileNotFoundException ex){
            ex.printStackTrace();
        }

        String s = null;
        do{
            s = br.readLine();
            pw.println(s);
        }
        while((s = br.readLine())!=null);

        br.close();
    }

    /* Main method */
    public static void main(String[] args) throws IOException{

        CharacterFileReaderAndFileWriter cfr = new CharacterFileReaderAndFileWriter();

        cfr.readFromFile();
    }

}
</code></pre>
