Fixed bug where not all files from a directory were being read properly