your break is outside of the loop. if you run this: break you will get the same error because that's exactly what your doing, there is no loop to break out of.