C++ basic file i/o, failure to read
<p>I am trying to replicate an exercise from a text book, however the file never reads and so the if statement is triggered telling me that I have not read the file. I have no error message or warnings. I am sure I am missing something fundamental but I just don't know what it could be.... 
I am running OSX, Clang7.0, using Qt (but I have also tried this in sublime text and it fails there too)</p>

<p>here is the code:</p>

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

using namespace std;

int main()
{
    ifstream file_reader ( "myfile.txt" );
    if ( !file_reader.is_open() )
    {
        cout&lt;&lt;"Could not open file!"&lt;&lt;'\n';
    }
    int number;
    file_reader &gt;&gt; number;
    cout&lt;&lt;number;
}
</code></pre>

<p>The file is in the same directory as the program files.
It is a .txt file simply containing:</p>

<pre><code>12 a b c 
</code></pre>

<p>I have tried putting the full path and had a look at some similar threads but it does not seems to be the same problem as <a href="https://stackoverflow.com/questions/1377078/problem-opening-file-c">this</a></p>

<p>Thanks for any help in advance</p>