Question 1
Topic: Control Structures and Iteration
Skill tested: Select loop control flow that safely handles records and termination conditions.
A penetration tester is reviewing a Python script that reads one line at a time from a large scan-results file. Blank lines should be ignored, lines beginning with `#` should be skipped, and processing should stop at the first line containing the exact marker `END`. The file may not contain that marker. The current implementation uses nested conditionals and a numeric index, and it sometimes processes the marker as a result. Which approach most directly implements the required behavior while avoiding unnecessary index management?
Direct iteration over a file processes lines sequentially without maintaining an index. `break` stops the loop as soon as the sentinel is reached, while `continue` skips only the current blank or comment line. Removing the line ending before comparison makes an exact marker comparison practical. The list-and-index approach adds memory and boundary risks, and `index