title: Append strings to a file based on a particular string position
body: <p>I have cucumber feature file(<code>test.feature</code>)</p>
  
  <pre><code>Feature: annotation  
  Background: 
  User navigates to Facebook 
  Given I am on Facebook login page 
  
  Scenario: When I enter username as "TOM" 
  And I enter password as "JERRY" 
  Then Login should fail 
  
  Scenario: When I enter username as "TOM" 
  And I enter password as "JERRY" 
  Then Login should fail 
  But Relogin option should be available
  </code></pre>
  
  <p>And  need to add tags (incrementing order) via java code .like</p>
  
  <pre><code> Feature: annotation  
  Background: 
  User navigates to Facebook 
  Given I am on Facebook login page 
  @tag1
  Scenario: When I enter username as "TOM" 
  And I enter password as "JERRY" 
  Then Login should fail 
  @tag2
  Scenario: When I enter username as "TOM" 
  And I enter password as "JERRY" 
  Then Login should fail 
  But Relogin option should be available
  </code></pre>
  
  <p>tags will be added in the incrementing order.Is there any possible way to add @tag above the string 'Scenario:'</p>
  
  <p>How can it is possible with java code.Any solutions.</p>
  
  <p>I tried with following code.But not able to procced to append to the position above the string 'Scenario:'</p>
  
  <pre><code> int count =0;
  
             BufferedReader bufferedReader = new BufferedReader(new FileReader("test.feature"));
             FileWriter writer = new FileWriter("test.feature");
             while ((line = bufferedReader.readLine()) != null) { 
                  if (line.trim().startsWith("Scenario")) {
                      count++;
                      writer.write("tag"+count);
  
                  }
             }
             //Final Dump data here 
              writer.close();        
             bufferedReader.close();
  </code></pre>