OPENFILE ... FOR WRITE
Opens the file Scores.txt in write mode so data can be written into it with WRITEFILE. The file must be opened before writing. Keywords are in capitals.
Understanding OPENFILE ... FOR WRITE in IGCSE Computer Science Paper 2
What it does: The file identifier "Results.txt" is a string, and FOR WRITE states the mode explicitly, which is good practice. 0478 pseudocode writes keywords in capitals, so OPENFILE, FOR and WRITE are all uppercase. A file must be opened before you write to it. Opening comes first, then WRITEFILE. FOR WRITE opens a file for writing. FOR READ opens a file for reading. The keyword is OPENFILE, not OPEN.
Common mistakes: The file was opened FOR WRITE, so data must be put into it with WRITEFILE. READFILE reads data out of a file. The line should be WRITEFILE "Names.txt", Name. The program wants to write Score into the file, so the file must be opened in write mode. FOR READ only allows reading. It should be OPENFILE "Data.txt" FOR WRITE.
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
OPENFILE "Scores.txt" FOR WRITEFill in the Blanks
Spot the Error
Student with a class code? Join your class →