Fix condition for string index out of range check.