Why programs store data in a file
A file keeps data on storage so it still exists after the program closes, unlike variables. The program can read it back next time it runs, such as a saved high score or a list of names.
Understanding Why programs store data in a file in IGCSE Computer Science Paper 2
What it does: WRITEFILE puts the data into the file on storage, so the names survive after the program closes and can be read back later. READFILE gets data that was stored earlier, so the program can use a value saved on a previous run.
Common mistakes: The file is open for WRITE and the aim is to save the score so it survives after the program ends. The line should be WRITEFILE "score.txt", Score, not READFILE. READFILE needs a comma between the file name and the variable that will store the saved name. It should be READFILE "names.txt", Name.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 479–488) and word search (Modules 479–499).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
fileFill in the Blanks
Spot the Error
Student with a class code? Join your class →