Closing an output file steam - does it need to be flushed?

I was using this macro without the flush but the last value in the last line was missing
sometimes. On a quick check, adding the flush may have fixed it.
This looks like a problem with the ofstream flushing when destoryed
on going out of scope. Is there a close or something to use?

// possible bug/ feature - last element of last dropped
// sometimes with the ofs.flush
macro mmsave(fn,u,Xh)
ofstream ofs(fn);
Xh xx=x;
Xh yy=y;
int n=u[].n;
for(int i=0; i<n; ++i)
{ ofs<<xx[][i]<<" "<<yy[][i]<<" "<<u[][i]<<endl; ofs.flush;  }
} catch (...) { cout<<" throw during save to   "<<fn<<endl; cout.flush;  }
} // EOM
                                                                    30,1          80%