loop structures and booleans gets the next line from file as string at the end of the filereadline(returns an empty stringwhich we can use as sentinel value here is general pattern for an end-of-file loop using readline()in python line infile readline(while line !""process line line infile readline(at first glanceyou may be concerned that this loop stops prematurely if it encounters an empty line in the file this is not the case remembera blank line in text file contains single newline character ("\ ")and the readline method includes the newline character in its return value since "\ !""the loop will continue here is the code that results from applying the end-of-file sentinel loop to our number averaging problemaverage py def main()filename input("what file are the numbers in"infile open(filename,' 'sum count line infile readline(while line !""sum sum eval(linecount count line infile readline(print("\nthe average of the numbers is"sum countmain(obviouslythis version is not quite as concise as the version using the for loop in pythonyou might as well use the latterbut it is still good to know about end-of-file loops in case you're stuck programming in less elegant language nested loops in the last you saw how control structures such as decisions and loops could be nested inside one another to produce sophisticated algorithms one particularly usefulbut somewhat tricky technique is the nesting of loops let' take look at an example program how about one last version of our number averaging problemi promise this is the last time 'll use this example suppose we modify the specification until