Write an if statement to halt program if the program fails to opne a file. Assuem the file to be opened has name \"stats.dat\". Solution C++ program #include #include using namespace std; int main () { ifstream infile; infile.open (\"stats.dat\"); if (infile.is_open()) { while (infile.good()) cout << \"file opened successfully\" << endl; infile.close(); } else { cout << \"Error opening file\"; } return 0; }.