I think i have coded the program correctly but when I try to run it, it doesnt run...
Can you be more specific about what happens when it "doesn't run"? Does the program not start at all? Does it ask you for a filename but then give an error? Does it get past the filename part and loop forever? Does it not loop at all? Did you try to debug your code? We need more information to help you.
Dont write
using namespace std;
Try without it. It worked on my pc. :-D
You need a newer compiler, dude. Yours is non-compliant with standard C++.