added loop over all files and added an automated way of reading input data