Within your block
for (i = 0; i < 6; ++i )
{
if ( students >> studentid[i] >> fname[i] >> lname[i] >> Q1[i] >> Q2[i] >> Q3[i] >> MidTerm[i] >> Q4[i] >> Q5[i] >> Q6[i] >> Final[i])
you have cout << all your stuff
CalculateAverage() //prints out one average (no line break or spaces)
out << all your stuff //sends to file silently
CalculateAverage() //prints out the second avg
So bring back your average function that returns a double, tack that on the end of your << chain (for both cout and out, e.g cout << var1<<var2<< Final<<CalculateAverage()<<endl;) and you'll have your average once and getting sent to the right spots.