Because once the first while loop has run it's course, F is "empty." Think of it like a book, if I say to you, "flip through all the pages in the book," and you finish it, so it's on its back cover, and I say: "Flip through all the pages in the book!" You can't without fliping it over and starting fresh.
A:
close(F);
open(F, "/etc/passwd");
between the whiles, is the equivalent of flipping the book over so you can flip through the pages again.
seek(F, 0, 0);
does something similar, only it doesn't completely close and reopen the book, think of this as just flipping the pages back to the beginning. I hope it makes sense :)