Added
A penetration-testing team processes a large newline-delimited file of observed hostnames. Blank lines and comment lines beginning with # must be ignored, while valid lines are normalized to lowercase and counted. The file is too large to load into memory, and malformed input should not stop processing later lines. Which loop design best meets the requirements while keeping the per-line handling clear?
Iterating over the file object reads it incrementally, avoiding memory growth proportional to the entire file. Using continue skips only the current blank or comment line, and a per-line exception handler lets later records proceed after malformed input. readlines() retains the full file in memory, so it conflicts with the stated scale constraint. A single read() in the while loop consumes all input rather than one line per iteration. break stops processing at the first ignored line instead of skipping it.