title: read 4 lines after specific delimiter encountered c++
body: <p>I've been trying to create simple program, that can works as cash register. It is suppose to read from a file the followings: 
  - name, 
  - price, 
  - tells if its fruit or vegetable ,
  - calories </p>
  
  <p>In my opinion the best way would be to detect identify number (something like barcode) and then read 4 lines and get 4 strings after ":" delimiter. </p>
  
  <p>Here is the txt file that i've created:</p>
  
  <pre><code># Vegetables #
  
  Iden number             :   11
  Name                    :   Carrot
  Price       [zl/kg]     :   2
  Group                   :   Vegetable
  Calories    [cal/100 g] :   33
  
  Nr Iden                 :   12
  Name                    :   Tomato
  Price       [zl/kg]     :   4
  Group                   :   Vegetable
  Calories    [cal/100 g] :   20
  
  Iden number             :   13
  Name                    :   Cucumber
  Price       [zl/kg]     :   1
  Group                   :   Vegetable
  Calories    [cal/100 g] :   14
  
  # Fruits #
  
  Iden number             :   21
  Name                    :   Apple
  Price       [zl/kg]     :   2
  Group                   :   Fruit
  Calories    [cal/100 g] :   52
  
  Iden number             :   22
  Name                    :   Orange
  Price       [zl/kg]     :   4
  Group                   :   Fruit
  Calories    [cal/100 g] :   47
  
  Iden number             :   23
  Name                    :   Kiwi
  Price       [zl/kg]     :   1
  Group                   :   Fruit
  Calories    [cal/100 g] :   60
  </code></pre>
  
  <p>Here is the code that detect delimiters and ignore empty lines or the one that starts with "#". But i don't know how to read only 4 following lines after detected identy_number.</p>
  
  <pre><code>    int main()
  {
    string line;
    ifstream plik ("baza_danych_produktow.txt");
    if (plik.is_open())
    {
      while ( getline (plik,line) )
      {
      line.erase(std::remove_if(line.begin(), line.end(), ::isspace),line.end());
  
       if(line[0] == '#' || line.empty()){ // if line starts with # or is empty - ignore
              continue;
          }
  
      auto delimiterPos = line.find(":");
      auto name = line.substr(0, delimiterPos);
      std::string value = line.substr(delimiterPos + 1);
      cout &lt;&lt; value;
      cout &lt;&lt; endl;
      }
      plik.close();
    }
  
    else cout &lt;&lt; "Unable to open file";
  
    return 0;
  }
  </code></pre>
  
  <p>My code display every string after ":" delimiter in every single line of file that is not empty or do not start with "#".</p>
  
  <p>Here is the output:</p>
  
  <pre><code>11
  Carrot
  2
  Vegetable
  33
  12
  Tomato
  4
  Vegetable
  20
  13
  Cucumber
  1
  Vegetable
  13
  21
  Apple
  2
  Fruit
  52
  22
  Orange
  4
  Fruit
  47
  23
  Kiwi
  1
  Fruit
  60
  </code></pre>
  
  <p>Could you please help me with that, so the output for example <strong>input: 11</strong> would look like this?</p>
  
  <pre><code>Carrot
  2
  Vegetable
  33
  </code></pre>
  
  <p>Best regards.</p>