Error in reading from a .txt file in c++
<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;
int main()
{
    //reading the text file
    ifstream inputFile("testfile1.txt");
    inputFile.open("testfile1.txt");
    while(!inputFile.eof())
    //eof till end of file, reads the txt till end of file
    {
        string str;
        getline(inputFile,str);
        cout &lt;&lt;str&lt;&lt; endl;

    }
        inputFile.close();

    return 0;
}
</code></pre>

<p>// The problem that i am having is that it doesn not read the file or anything in it. Doing nothing it says Program ended with exit code: 0. Could anyone check the mistake in the code</p>