updated to read one file at a time