#include	<iostream>
#include	<fstream>
#include	<string>

using std::clog; 	using std::cerr;
using std::endl;	using std::string;
using std::ifstream;	using std::ofstream;

int main(int argc, char **argv)
{
	if (argc < 3) {
		cerr << "Usage: " << argv[0] 
			<< " <infile1> <infile2> ... <out>" << endl;
		return 1;
	}
	ofstream output(argv[--argc]);
	if (! output) {
		cerr << "Cannot open output file" << endl;
		return 1;
	}

	while (--argc) {
		ifstream input(*++argv);
		if (! input) {
			cerr << "Cannot open input file" << endl;
			return 1;
		}
		clog << "Processing " << *argv << endl;

		string s;
		while (getline(input, s)) {
			output << s << endl;
		}
	}
	return 0;
}
