Added error checking during data read