Presumably you're expecting to see "nn" on screen, as that's the only thing you output to screen. I expect it's being buffered. Replace cout<<"nn";
with cout<<"nn" << endl;
How do you know it's meant to? It's about time you started debugging for yourself.
For example, put this: cout << "Now writing to file " << endl;
on line 40 so that you can see if your code ever actually gets to writing output to file.
If it doesn't, then you know that the code is never reached and you can put some logging lines earlier to see what happens so that it never gets there.
ok i tried and it worked thank you. the problem is about the issue that there are for loops in the code and takes a little time to debug and i look very soon to the file so ş can't see the output.