I am trying to close a file using a function I created called closeFile

I tried to pass in filedir but it did not work. I tried the code below and it does not work. Can somebody help me here. The main works and If I move the code that is closeFile to main it works but does not in the function.

need some help here

Thanks in advance.


here is part of my main:
// fileOutpName is entered from the GUI

string filedir = "C:\\training_output\\" + FileOutputName;

out_stream.open (filedir.c_str());

globalfile = filedir; // set filedir to a global string
....
...
....
closeFile(); // call closeFile


void CStrengthCoachDlg::closeFile(void) //close out file
{
ofstream out_stream;
out_stream.close();
string systemcall = "START " + globalfile;

system(systemcall.c_str());


return;
}