use fileinput instead of manual processing the files