title: C++ read large file and save it to a string and remove specific random words
body: <p>I was trying to find a way for read a semi-large file (130 MB) and save it into a string fast and remove all random words in the string, like this:</p>
  
  <pre><code>File.txt:
  0x0239183 (10): Hello
  0x0039123 (1): Test
  ...
  </code></pre>
  
  <p>The only word that the program should take is the one after the 2 points, not counting the space, for example ("Hello" &amp; "Test" in this case).</p>
  
  <p>I tried with this code:</p>
  
  <pre><code>fstream f(legitfiles.c_str(), fstream::in );
  string s;
  while(getline( f, s, '\0')){
      size_t space_pos = s.find(" ");    
      if (space_pos != std::string::npos) {
          s = s.substr(space_pos + 1);
      }
  }
  cout &lt;&lt; s &lt;&lt; endl;
  f.close();
  </code></pre>
  
  <p>But when I start the program the only word that remove is the first of the first line.</p>
  
  <pre><code>Output File.txt:
   (10): Hello
  0x0039123 (1): Test
  ...
  </code></pre>