Fixed the problem with the looping. replaced fgets with scanf.
removed commented out code.