fix loop if EOF is reached during error recovery