Modularized code to read file/rows by file type