title: Skip certain number of lines while reading a text file - BufferedReader Java
body: <p>I have several files in a directory that I intend to skip a certain number of lines. The only way to get the lines to skip is to get the first occurrence of  a line that has a character length of 1. The only available information is that the line occurs anywhere before line number 60. So I have written the following method to attempt to skip the lines before the character. But I end up getting the same file as the original file:</p>
  
  <pre><code>public static void editSplitFiles(File sourceDir) {
      FilenameFilter only = new OnlyExt("RPT");
      log.debug("Editing Split Files........");
      String[] filenames = sourceDir.list(only);
      try {
          for (int k = 0; k &lt; filenames.length; k++) {
              FileInputStream fs = new FileInputStream(sourceDir.getAbsolutePath() + System.getProperty("file.separator") + filenames[k]);
              BufferedReader br = new BufferedReader(new InputStreamReader(fs));
              FileOutputStream fos = new FileOutputStream(sourceDir.getAbsolutePath() + System.getProperty("file.separator") + filenames[k] + ".LST");
              BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
              String strLine;
              int num = 0;
              int splitLine = 0;
              while ((strLine = br.readLine()) != null) {
                  num++;
                  if (strLine.length() == 1) {
                      splitLine = num;
                  }
  
                  bw.write(strLine);
                  bw.newLine();
                  bw.flush();
              }
              if (splitLine &lt; 60) {
                  log.debug("File Name" + filenames[k] + "Line Number - " + splitLine);//This gives me the correct line number where the character is for each file.
                  br.readLine();
              }
  
              fs.close();
              br.close();
              fos.close();
              bw.close();
          }
      } catch (Exception asd) {
          log.debug(asd.getMessage());
      }
  }
  </code></pre>
  
  <p>I am not sure what I am doing wrong but it looks like the file is getting written before I skip. How do I accomplish this?</p>
  
  <p><strong>EDIT</strong>
  The files looks like this:
  <a href="https://i.stack.imgur.com/H8CeH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H8CeH.png" alt="Sample File"></a></p>