Your line numbers seem to be off from the master copy of the profile. But if I had to guess, the loop is due to Thieving Thistleleaf I've changed the conditional logic here that should prevent this.