#include <iostream>
#include <type_traits>
#include <vector>
#include <memory>
#include <string>
#include <functional>
#include <map>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <unordered_map>
using namespace std;
int main()
{
//-----------------------------------------------------------------------------vvvvvvvvvvvvvvv---->explicitly use trunc
std::fstream create_new_file{ "output.txt", ios_base::in | ios_base::out | ios_base::trunc}; // trunc is used to override everything in the file
std::cout << "Would you like to add some changes?" << std::endl;
std::unique_ptr<int> choice_two = std::make_unique<int>(0);
std::cin >> *choice_two;
if (*choice_two) {
while (true)
{
std::cout << "Enter the changes which u wanna make" << std::endl;
std::unique_ptr<std::string> changes = std::make_unique<std::string>("");
std::cin >> *changes;
if (*changes == "stop") {
create_new_file.close();
break;
} // stop if the the text is "stop"
create_new_file << *changes << "\n";
std::cout << "Successfully added \"" << *changes << "\"" << " to the file" << std::endl;
}
}
}