Can you please tell the details of the error. You never mentioned the exception you are getting for the looping.