corrected collection of array of inputs and opening of infile