title: Text parsed line by line with loop scanning grouped content
body: <p>In a txt file, populations 0 and 1 each has its own parameter values, formatted like this:</p>
  
  <pre><code>population 0
  gK 9
  gNa 35
  gL 0.1
  
  population 1 
  gK 9
  gNa 35
  gL 0.1
  </code></pre>
  
  <p>The file is loaded using ifstream, parsed using getline and stringstream. </p>
  
  <p>I try making a loop such that when a line containing "population 0" is encountered, its parameters are read line by line according to the template "contents >> param_name >> param_val", 
  parameter name is compared to an expected string, and its value goes into a corresponding pointer array (ie: population 0, gK=9 goes into gK[0]) </p>
  
  <p>Reaching the last expected parameter, or reaching next population (i+1), jumps to seek next population in the text (i+1).</p>
  
  <pre><code>void Parameters::Initialize(ifstream &amp; pfile) {
   stringstream char_content;
   string temp;
   string line;
   string param_name;
   double param_val{ 0 };
  
   while (getline(pfile, line)) {
  
      stringstream contents(line);
  
  
      if (contents.rdbuf()-&gt;in_avail() == 0) { // if 
          continue;
      }
  
      if (!(contents &gt;&gt; param_name &gt;&gt; param_val)) { 
          printf("error reading line from file. position: file %s line %d\n", __FILE__, __LINE__);
          throw "error reading file";
      }
  
  
  for (int i { 0 }; i &lt;= 2; ++i) { 
  
          if ((param_name.compare("Population") == 0) &amp;&amp; (param_val == i)) { //if condition satisfied, get subsequent lines up to next population
  
          if (param_name.compare("gK") == 0); gK[i] = param_val;
          if (param_name.compare("gNa") == 0); gNa[i] = param_val;
          if (param_name.compare("gL") == 0); gL[i] = param_val;
  
          if ((param_name.compare("Population") == 0) &amp;&amp; (param_val == i + 1)) continue;
          }
      }
  }
  }
  
  int main (){
      cin &gt;&gt; file; // .txt file
      std::ifstream paramFile(file);
  
      P.Initialize(paramFile);
  }
  </code></pre>
  
  <p>Would appreciate if someone could help make a working version.</p>