//Reading the last name from the file
ifstream file;
file.open("studentName.txt");
char name[20] ;
file>>name;
cout<<"The last user was: "<<name<<"\n";
file.close();
//Replace the last student name with the new one in the text file
cout<<"What is your name?: ";
cin>>name;
name[0]=toupper(name[0]);
ofstream file2;
file2.open("studentName.txt");
file2<<name;
file2.close();
When I run the program I don't see anything in studentName.txt What's even more weird is that I can run the program without the txt file and it will read somewhere the name of the last user?