Sep 12, 2013, 10:17 AM
Re: [Drinc3] open and close file before each while-looping through file?
EDIT: Why isn't the code properly formatted?You need to use the code tags, which is the button at the bottom-left of the input text box.
After the first while loop the filepointer is positioned at the end of the file. If you want to loop over the contents a second time, you need to either use the seek function to reset the file pointer, or close and reopen the file. Between these 2 options, using seek would be better.
However, a better option would be to rework your logic and only loop over the file once.
(This post was edited by FishMonger on Sep 12, 2013, 10:17 AM)