/* a11-1-1.c */
#include <stdio.h>
#include <string.h>

int main(void)
{
	FILE *fin, *fout;
	char str[256];

	if( (fin = fopen("color.txt", "r") ) == NULL) {
		printf("Input file open error.\n");
		return 1;
	}
	if( (fout = fopen("green.txt", "w") ) == NULL) {
		printf("Output file open error.\n");
		fclose(fin);
		return 1;
	}

	while(fgets(str, sizeof(str), fin) != NULL) {
		if (strstr(str, "green") != NULL) {
			fputs(str, fout);
		}
	}

	fclose(fin);
	fclose(fout);

	return 0;
}
