Reading and comparing lines from a text-file
<p>I have this code that I want to read lines from a text-file and find unique codes from that line. Here is a little of what my text-file reads:</p>

<blockquote>
  <p>AGU UAC AUU GCG CGA UGG GCC UCG AGA CCC GGG UUU AAA GUA GGU GA</p>
  
  <blockquote>
    <p>GUU ACA UUG CGC GAU GGG CCU CGA GAC CCG GGU UUA AAG UAG GUG A</p>
  </blockquote>
  
  <p>UUA CAU UGC GCG  M  GGC CUC GAG ACC CGG GUU UAA AGU AGG UGA</p>
  
  <p>UGG  M  AAA UUU GGG CCC AGA GCU CCG GGU AGC GCG UUA CAU UGA</p>
</blockquote>

<p>I want to find the lines that contain the letter <code>'M'</code> and make them separate strings so that I can break them up even more and compare them. I am having a little trouble though.
I am trying to find them and the assign it to a string, but it seems to assign all the lines to the same string. This is what I have so far:</p>

<pre><code>ifstream code_File ("example.txt");   // open text file.
if (code_File.is_open()) {
   while (code_File.good()) {
      getline(code_File,line);    //get the contents of file 
      cout  &lt;&lt; line &lt;&lt; endl;     // output contents of file on screen.
      found = line.find_first_of('M', 0);               // Finding start code
      if (found != string::npos) {
         code_Assign.assign(line, int(found), 100);        
         /* assign the line to code_Assign and print out string from where I 
            found the start code 'M'. */
         cout &lt;&lt; endl &lt;&lt; "code_Assign: " &lt;&lt; code_Assign &lt;&lt; endl &lt;&lt; endl;
</code></pre>

<p>ED: Should I use string replace instead of assign?</p>
