added read file error checking