Its doing as defined in the code, when the iteration reached more than iteration limit, it reflects the message as mentioned within the code
if count == Iteration_limit + 1
error('Iteration limit reached. Iteration did not converge.')
Before getting the break statement, your code reached the limit, please check, there may be abs(f) never less than Tolerance
Its simple code, debug it step by step, ensure that it reached the break statement before reched the iteration limit, ensure that f is changing in right direction during each iteration. The loop execute the iteration as number of times=iteration limit.
Choose the right parameters values or codition to reached the break before reached to operation limit, see the tolerance value also.