Getting code to run is only half of an assignment. The other half is proving that the code satisfies every requirement in the specification. Missing requirements like "write output to a file" are usually not a coding problem — it is a reading and verification problem.
Why this happens
- You focus on the technical challenge and treat the instructions as background noise.
- Requirements live in short-term memory and get pushed out while debugging.
- You stop as soon as the script "works," before checking deliverables.
A repeatable workflow
- Read the requirements aloud, one at a time. Do not skim.
- Convert each requirement into a checklist item. For example:
□ output written to results.txt. - Decide output file names and formats before writing logic. Hardcode them or accept them as CLI arguments. For pipeline-ready scripts, see Designing Python Scripts for Automation and Pipelines.
- Write output handling first. Open the file and decide what will be written. Then implement the analysis. Common pitfalls when writing files are covered in Python File Handling Pitfalls Cheat Sheet.
- Run and verify. After the script runs, inspect the output file:
cat results.txt,ls -l results.txt, or open it in an editor. - Check every box. If a requirement is unchecked, the assignment is not done.
Example
import sys
input_path = "data.bin"
output_path = "output.txt"
with open(input_path, "rb") as f:
data = f.read()
result = f"Read {len(data)} bytes from {input_path}\n"
with open(output_path, "w") as f:
f.write(result)
print(f"Done. Wrote {output_path}")
In security work
- Pentest reports, logs, and artifacts must be saved explicitly; validating and reporting findings is covered in Lesson 12: Validate Findings Manually and Write a Professional Penetration Test Report.
- A working exploit or scraper is useless if the output is only printed to stdout and lost.
- Reverse engineering tasks often require saving reconstructed binaries, disassembly, or notes to disk, as discussed in Building Pentest and RE Automation Tools.
This habit separates "I can code" from "I can deliver."