Solved the problem

Fixed the unending loop and moved tries++ to the end of the loop instead of in the conditionals.