Why std::cin string input asking me for each space
<p>This week I started studing a text files in C++ and in my exercice I have to do a program that the user enter the lines in the file, but... for each space that the user enters, the program asking the new to user.</p>

<p>Here is my code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

int main(void){
    ofstream myfile;
    string answer;

    do{
        cout &lt;&lt; "Insert a line in the file[END to finalize]: ";
        cin &gt;&gt; answer;
        myfile.open("example.txt");
        myfile &lt;&lt; answer;
        myfile.close();
    }while(answer != "END");
}
</code></pre>

<p>The result is:</p>

<blockquote>
  <p>Insert a line in the file[END to finalize]: <strong>Hello my friend</strong></p>
  
  <p>Insert a line in the file[END to finalize]: Insert a line in the
  file[END to finalize]: Insert a line in the file[END to finalize]:</p>
</blockquote>
