Updated reader to loop over files and directories