Trying to read this file in parts. read some part and skip some
<p>I am trying to read a file, I want to read some part of the file and skip some part untill I get to the end of the file. This is what I have but I am not getting my desired result. The idea is to read through all the lines and check if it starts with either "CH" or "CL" if not move to the next line until the end of file and store all those that match the criteria</p>

<pre><code> new BufferedReader (new FileReader ("c:\\demo5.properties\\"));
    while(( br.readLine()) != null ){
        if (br.readLine().startsWith("CH") ||  br.readLine().startsWith("CL")) {
        buf = new StringBuffer();
        buf.append( br.readLine());

        while (br.readLine()!= null &amp;&amp; !br.readLine().startsWith("#") &amp;&amp;  !br.readLine().contains("claimID")){
            buf.append( br.readLine()).append( "\n" );
        }
         z = buf.toString();

         System.out.println(z);

        s3+= z;
    }
        br.readLine();
</code></pre>

<p><strong>FILE FORMAT</strong></p>

<pre><code> CH.field 
 CH.field
 CH.field
 CH.field
 CH.field
 #CH.field
 #CH.field
 #CH.field
 #CH.field
 *********
 **
 *********
 CL1.field
 CL1.field
 CL1.field
 CL1.field
 CL1.field
 *****************
#Result.CL1.field
#Result.CL1.field
#Result.CL1.field
Result.CL1.field
*********
CL4.field
CL4.field
CL4.field
#CL4.field
#CL4.field
#CL4.field
***********

   #Result.CL4
  #Result.CL4
  #Result.CL4
  #Result.CL
 Result.CL4
  CL5.field
 CL5.field
 CL5.field
 #CL5.field
 #CL5.field
</code></pre>

<p>OUTPUT</p>

<pre><code>CH.fieldCH.field

CL1.field#Result.CL1.field
CL4.field
CL4.field
</code></pre>

<p>#CL4.field</p>

<pre><code>CL5.fieldCL5.field
</code></pre>
