title: Read in a string from file line per line and just the first word
body: <p>I got this Code from <a href="https://www.c-plusplus.net/forum/286828" rel="nofollow">here</a>.</p>
  
  <pre><code>#include &lt;iostream&gt; 
  #include &lt;fstream&gt; 
  #include &lt;string&gt; 
  #include &lt;limits&gt; // numeric_limits 
  
  void print_line( const std::string&amp; filename, int lnNo ) 
  { 
      using namespace std; 
      ifstream file( filename.c_str() ); 
      if( !file.is_open() ) 
      { 
          cerr &lt;&lt; "Fehler beim Oeffnen der Datei " &lt;&lt; filename &lt;&lt; endl; 
          return 0; 
      } 
      for( ; lnNo &gt; 1; --lnNo ) 
          file.ignore( numeric_limits&lt; streamsize &gt;::max(), '\n' ); 
      string line; 
      if( !getline( file, line ) ) 
      { 
          cerr &lt;&lt; "Fehler beim Lesen aus der Datei " &lt;&lt; filename &lt;&lt; endl; 
          return 0; 
      } 
      cout &lt;&lt; line &lt;&lt; endl; 
  } 
  
  int main () 
  { 
      using namespace std; 
      for( int lnNo; cin &gt;&gt; lnNo; ) 
          print_line( "input.txt", lnNo ); 
      return 0; 
  }
  </code></pre>
  
  <p>This reads in a whole line specified by <code>lnNo</code>. What do I have to change when I just want to read in the first word per line?</p>
  
  <p>Thanks in advance.</p>