This code should prompt input for 5 fields and then write them put them into an array and write to a file. I get an error message when I close the file, anyone see the problem? [side note, the "TheScreen" is what appears with the info entered in, it is not aprt of the problem.]
void addNewCustomer(){
fstream CustomerFile;
CustomerFile.open("database_file.txt");
int maxCustomerNumber;
maxCustomerNumber = 1;
customerDataBase customerArray[maxCustomerNumber];
TheScreen(customerArray[k]);
cout<<endl<<"please enter last name: ";
cin>>customerArray[k].lastName;
CustomerFile<<customerArray[k].lastName<<",";
system ("cls");
TheScreen(customerArray[k]);
cout<<endl<<"please enter first name: ";
cin>>customerArray[k].firstName;
CustomerFile<<customerArray[k].firstName<<",";
system ("cls");
TheScreen(customerArray[k]);
cout<<endl<<"please address name: ";
cin>>customerArray[k].addr1;
CustomerFile<<customerArray[k].addr1<<",";
system ("cls");
TheScreen(customerArray[k]);
cout<<endl<<"please other address information name: ";
cin>>customerArray[k].addr2;
CustomerFile<<customerArray[k].addr2<<",";
system ("cls");
TheScreen(customerArray[k]);
cout<<endl<<"please enter e-mail name: ";
cin>>customerArray[k].eMail;
CustomerFile<<customerArray[k].eMail<<",";
system ("cls");
TheScreen(customerArray[k]);
CustomerFile.close;
}