contains best-practice for looping over multiple input files (to avoid error caused by too many open file handles!)