#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void appendStringToFile(const string& textToAdd, const string& filename) {
ofstream outFile(filename, ios::app);
if (outFile.is_open()) {
outFile << textToAdd << endl;
outFile.close();
cout << "String appended to file '" << filename << "' successfully." << endl;
} else {
cout << "Error: Unable to open the file '" << filename << "'." << endl;
}
}
int main() {
string textToAdd = "This is new data appended to the file.";
string filename = "output.txt";
appendStringToFile(textToAdd, filename);
return 0;
}