Problem with file loop and reading into map
<p>The while loop I have while reading in from a file doesn't break. I'm not sure what the problem is. If you need any more information just ask.</p>

<p>Code:</p>

<pre><code>#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;iterator&gt;

using namespace std;

class Customer {
public:
    string name;
    string address;
    Customer() {}
};

class Purchase {
public:
    string product_name;
    double unit_price;
    int count;
    Purchase() {}
    Purchase(string pn, double up, int c) :product_name(pn), unit_price(up), count(c) {}
};

// Function Object for comparison in map container
struct Cmp_name {
    bool operator()(const Customer&amp; first, const Customer&amp; second)
    { return first.name &lt; second.name; }
};

// ostream overloads
ostream&amp; operator&lt;&lt;(ostream&amp; out, const Customer&amp; c)
{
    out &lt;&lt; c.name &lt;&lt; '\n'
        &lt;&lt; c.address &lt;&lt; '\n';
    return out;
}

ostream&amp; operator&lt;&lt;(ostream&amp; out, const Purchase&amp; p)
{
    out &lt;&lt; p.product_name &lt;&lt; '\n'
        &lt;&lt; p.unit_price &lt;&lt; '\n'
        &lt;&lt; p.count &lt;&lt; '\n';
    return out;
}

istream&amp; operator&gt;&gt;(istream&amp; in, Customer&amp; c)
{
    getline(in, c.name);
    getline(in, c.address);
    return in;
}

istream&amp; operator&gt;&gt;(istream&amp; in, Purchase&amp; p)
{
    getline(in, p.product_name);
    in &gt;&gt; p.unit_price &gt;&gt; p.count;
    return in;
}

int main()
{
    cout &lt;&lt; "Enter file to read orders from: \n";
    string file;
    cin &gt;&gt; file;
    ifstream is(file.c_str());
    if (!is) cerr &lt;&lt; "File doesn't exist.\n";

    multimap&lt;Customer, Purchase, Cmp_name&gt; orders;

    while (!is.eof()) {
        Customer c;
        Purchase p;

        is &gt;&gt; c;
        is &gt;&gt; p;

        orders.insert(make_pair(c,p));
    }

    for (multimap&lt;Customer, Purchase, Cmp_name&gt;::iterator it = orders.begin(); it!=orders.end(); ++it)
        cout &lt;&lt; it-&gt;first &lt;&lt; it-&gt;second &lt;&lt; "\n\n";

}
</code></pre>
