用输入输出流进行打开指定文件并在每一行前加行号后输出到另一文本文件中,为何程序运行后第一个文本内的内容并没有被输出到第二个文本,第二个文本依然为空?

请各位路过大神帮忙指点,为何下述程序无法正确实现将src.txt的内容每行加行号后输出到dst.txt?本人在命令行窗口输入test.exe src.txt dst.txt后,打开相应目录下的dst.txt发现仍旧为空:

#include
#include
#include

int main(int argc, char * argv[])
{
strstream textfile;
{
ifstream in(argv[1]);
textfile << in.rdbuf();
}
ofstream out(argv[2]);

const int bsz = 100;
char buf[bsz];
int line = 0;
while (textfile.getline(buf, bsz))
{
    out.setf(ios::right, ios::adjustfield);
    out.width(1);
    out << ++line << ". " << buf << endl;
}

return 0;

}

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^