Set is not removing the duplicates : <p>I am having trouble putting a file of words into a set. I can read the file and the words go into the set but the set doesn't discard the repeated words. Here is the snippet of code that I believe is causing the problem. </p>

<pre><code>using namespace std;

while(readText &gt;&gt; line){

     set&lt;string&gt; wordSet;
     wordSet.insert(line);


     for (std::set&lt;std::string&gt;::iterator i = wordSet.begin(); i != wordSet.end(); i++)
        {
        cout &lt;&lt; *i &lt;&lt; " ";
        }

  }
</code></pre>

<p>the sample file is this
    1
    2
    2
    3
    4
    5
    5</p>

<p>and the output is exactly the same</p>
