writing a PC diagnostic program for my college project. No very little about coding. Problem is, the user has to be able to view error statistics of all runs of the program from a .dat or .txt file via a choice on the introductory menu of the program. I've just managed to get the dat. files to create and stay on the floppy disk but cant get them to append or be viewed. Every fresh start of the code produces blank records. The code I've used is as follows:

void main()
{
file0.open("a:\\errors.dat", ios::in |ios:ut |ios::app);
if (!file0)
{
cout <<"Error initialising file";
}
else
{
for (int index =4; index<4; index++)
{
file0 >>errors[index].error_type;
file0 >>errors[index].no_of_faults;
file0 <<errors[index].error_type;
file0 <<errors[index].no_of_faults;
}
}

file0.close();

file1.open("a:\\total_errors.dat", ios::in | ios:ut |ios::app);
if (!file1)
{
cout <<"Error initialising file";
}
else
{
file1 >>total_faults;
file1 <<total_faults;
}

file1.close();
menu();
}




in the choice function for the menu under switch I've written:



//Switch Function
case 3:
file0.open("a:\\errors.txt", ios:ut |ios::app);
if (!file0)
{
cout <<"Error writing to file";
}
else
{
for (int index =4; index<4; index++)
{
file0 <<errors[index].error_type;
file0 <<errors[index].no_of_faults;
}
file0.close();
file1.open("a:\\total_errors.txt", ios:ut |ios::app);
if (!file1)
{
cout <<"Error writing to file";
}
else
{
file1 <<total_faults;
}
file1.close();
exit(-1);
}
break;

any help or suggestions greatly appreciated