Add MAX_ITER to termination condition
Created by: jassak
Adds an iteration counter to main loop and terminates if counter exceeds MAX_ITER=20.
Created by: jassak
Adds an iteration counter to main loop and terminates if counter exceeds MAX_ITER=20.