Iterative DFS

Could someone rectify this and tell me what the error is. The stack operations are working properly, and the program is going into an infinite loop.