Better error handling in readFiles