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" << endl;
the problem with cout is okey now thank you but it doesn't write on file still.
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.
But now there is no problem