#include <stdio.h>
#include <string.h>

main (int argc, char *argv[]) {
	char string[81],*s;
	FILE *in,*out;

	if (argc > 2) {
		if (in = fopen (argv[1],"r")) {
			if (out = fopen (argv[2],"w")) {
				while (fgets (string,81,in)) {
					if (s = strrchr (string,'\n')) *s = 0;
					else s = string + strlen (string);
					while (s > string && isspace (*(s-1))) s--;
					*s = 0;
					fputs (string,out);
					fputc ('\n',out);
					}
				fclose (out);
				puts (argv[2]);
				}
			else {
				printf ("Error: could not open output file %s\n",argv[2]);
				exit (1);
				}
			fclose (in);
			}
		else {
			printf ("Error: could not open input file %s\n",argv[1]);
			exit (1);
			}
		}
	else
		printf ("Usage: %s infile outfile\n",argv[0]);
	}