title: Concatenation of strings is replacing first few characters
body: <p>When I'm trying to concatenate two strings the second string is replacing the first letters of the first string.</p>
  
  <p>I'm using the getline  function to get my input from a file, regex on the line to pick out the "UIN" of 9 digits, and trying to append another string onto the original, full line. Ex:</p>
  
  <pre><code>    string line; 
      ifstream in(infile);
      ofstream out("output.csv");
      getline(in, line);
      regex pat("(\\d{9})");
      smatch matches;
  
      if(regex_search(line, matches, pat))
      {
  
          line += ",65";
  
          cout&lt;&lt;line&lt;&lt;endl;
          out&lt;&lt;line&lt;&lt;endl;
  
      }
  </code></pre>
  
  <p>(of course Im doing other things in this statement but none operate on the string line so I left it out)</p>
  
  <p>The original line is</p>
  
  <pre><code>Alfonso Livingston,mattis@dolor.co.uk,800000092
  </code></pre>
  
  <p>And returned is</p>
  
  <pre><code>,65onso Livingston,mattis@dolor.co.uk,800000092
  </code></pre>
  
  <p>I saw <a href="https://stackoverflow.com/questions/21105873/unexpected-problems-concatenating-strings">this link</a> and have tried creating new strings i.e.<code>string newline(line);</code> and doing string casts(?) (<code>line += string(",65")</code>) but it all ends with the same results. I have also tried to use the append function and the push_back function. Any help would be much appreciated!</p>
  
  <p>edit:</p>
  
  <p>This is my entire function. The input is coming from a comma seperated value list, input.csv. I really cannot replicate this outside of this function, so I don't know if I can give a complete verifiable example.</p>
  
  <pre><code>void combine(string infile)
  {
      ifstream in(infile);
      ofstream out("output.csv");
      int size = getSize(infile);
      int hashVal;
      string line; 
      string listVals;
      getline(in, line);
      regex pat("(\\d{9})");
      smatch matches;
  
  
      if(regex_search(line, matches, pat))
      {
  
          hashVal = hash(stoi(matches[0]));
          listVals = table[hashVal].getFirst()-&gt;getElem();
          line += ",65";
          cout&lt;&lt;line&lt;&lt;endl;
          out&lt;&lt;line&lt;&lt;endl;
  
      }
  
  
  }
  </code></pre>
  
  <p>This isn't what the entire completed function is suppposed to do, but it's where I've had to stop to figure out this issue.</p>