fixed infinite loop while reading in the spec