fix bug when ampersand is last char on line

when the string being checked for numerical entities has an ampersand at the end of the string, the original code throws a warning because it checks the next character, past the end of the line