bug fixed for reading input file outside of the iteration loop.