Writing a complete file handling program in 0478 pseudocode
The order of a complete file program: declare variables, open the file in the right mode, read or write the data, then close the file. Keywords are in capitals and statements are indented.
Understanding Writing a complete file handling program in 0478 pseudocode in IGCSE Computer Science Paper 2
What it does: OPENFILE comes after DECLARE and before WRITEFILE. The mode FOR WRITE matches the job of saving data into the file. Comments starting with // and meaningful identifiers make a program easy to understand. In an exam answer, they show what the file is used for. The file identifier is a string, so it goes in double quotes. The Cambridge pseudocode layout uses capitals for keywords. A good comment states the purpose of the code. Vague comments do not help the reader. Describe the purpose of the file: data kept in a file is not lost when the program stops, unlike data held in variables.
Common mistakes: The program writes data with WRITEFILE, so the file must be opened in WRITE mode. Line 2 should be OPENFILE "names.txt" FOR WRITE. OPENFILE needs the file identifier (the file name as a string) before the mode. It should be OPENFILE "diary.txt" FOR READ.
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 500–522) and word search (Modules 500–538).
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
DECLARE, OPENFILE, WRITEFILE, CLOSEFILEFill in the Blanks
Spot the Error
Student with a class code? Join your class →