title: cannot read from a file by line using fstream; read by whole file ok
body: <p>1.i am trying to read a file line by line, yet it will not. i previously was reading the entire file in one step without a problem. i changed the vector receiving the data to a local vector as an experiment (without success). i suspect i doing something obviously wrong, except to me.</p>
  
  <pre><code>int
  full_file_read( std::vector&lt;std::string&gt; &amp;data ,
                  const std::string&amp; filename ,
                  bool is_binary )
  {
      std::string line ;
      std::ios_base::openmode openmode = std::ios::ate | std::ios::in ;
  
      if ( is_binary )
      {
          openmode |= std::ios::binary ;
      }
  
      std::fstream file( filename , openmode ) ;
  
      if ( !file )
      {
          std::cerr &lt;&lt; "Can't open input file! "
              &lt;&lt; filename &lt;&lt; std::endl ;
      }
  
      std::vector&lt;std::string&gt; text ;
      // to verify that it likes the push back for data is not the problem
  
      if ( file.is_open() )
      {
          while ( std::getline( file , line ) )
          {
              text.push_back( line ) ;
              // data.push_back( line ) ;
          }
      }
      else
      {
          std::cerr &lt;&lt; "Opening of " &lt;&lt; filename 
              &lt;&lt; " failed!" &lt;&lt; std::endl ;
      }
  
      std::cout &lt;&lt; "file contents: " &lt;&lt; std::endl ;
  
      for ( auto const&amp; c : line )
      {
          std::cout &lt;&lt; c &lt;&lt; ' ' &lt;&lt; std::endl ;
      }
  
      return 0 ;
  }
  </code></pre>
  
  <p>2.when running without using debug, i get a seg-fault. when in gdb, the while loop does not execute. data file is as follows</p>
  
  <pre><code>i have a comment here
  and another over there
  yet another in somewhere unknown
  for reasons only (dr) who noses
  NumParticles|SimWidth|SimHeight|ViewWidth|ViewHeight|Softener|Zoom|MouseX|MouseY|MassMin|MassMax|CenterMass|DiskMin|DiskMax
  10000000,327680,327680,1366,768,10,1,0,0,1,2,100000,2000000,5
  </code></pre>
  
  <p>tia</p>