#include<iostream>
#include<sstream>
#include<string>
#include<fstream>
using namespace std;
string process(const string& filename)
{
ostringstream os;
if(ifstream ifs(filename); ifs)
{
string line;
while(getline(ifs, line))
{
if(auto pos = line.find("link"); pos != string::npos)
{
pos = line.find('\"', pos);
auto end = line.find('\"', pos + 1);
os << process(line.substr(pos + 1, end - pos - 1));
continue;
}
os << line << "\n";
}
}
return os.str();
}
int main()
{
cout << process("text.txt");
cin.get();
}