modified to check multiple input files.