Thanks for the help guys. Dave, that did the trick and all is now well.

EVOE, I realized counter should have been an int but what do you mean about not using ++ with a double? My program was actually returning 1.#INF before it was suggested that I do that.