now correctly waiting until all files are read