This is a classic homework task - so I added the tag.
But you provided code -> +5 for that!
You are using a while loop - that one runs until the list is done.
So just switch that one to a for loop to get the desired 12 lines running.
Or add a counter and count the number of lines you've run through.
there is another for loop in there:
for (int counter=0; counter<=42; counter++){
}
Why is that one counting to 42?