The for loop is moving through the linked list until it reaches the end, as indicated by the next pointer being null.
Now, you've gotten your free help. Perhaps you could do a favor in return. USE CODE TAGS AROUND YOUR CODE. If you haven't read the "Before you post a query" thread, yet, please do that. Anything less is rude to your potential (free) helpers.