Just looking at your code I thought it might be a problem, it was not because it worked for me.
The next thing I would check is the spelling on the file name in the program compared to the file name.
I noticed that you open the file with "dictionary.txt", but in your error message you say "datafile.txt". This is an indication that something is different.
The two basic reasons for the file to not open is the spelling of the name or the file does not exist.
Lines 19 and 20 should be reversed because the pause is never reached because of the return. And it is best to avoid using "system" anything. There are many posts regarding the use of "system". Also you can read through this for suggestions to pause the program. http://www.cplusplus.com/forum/beginner/1988/
Line 18 should come after line 9. I prefer to open the file before I get into anything else.