READFILE: reading a single item of data
Reads one data item from the open file and stores it in the variable. The file must already be open in READ mode, and the variable's data type must match the item.
Understanding READFILE: reading a single item of data in IGCSE Computer Science Paper 2
What it does: The variable PlayerName, written after the comma, receives the item that READFILE reads from Names.txt. Declaring Score as INTEGER means it can hold a whole-number item read from the file, so the data types match. READFILE only works on a file that is already open in READ mode.
Common mistakes: READFILE only works on a file that is open in READ mode. The file was opened FOR WRITE, so line 2 should end with FOR READ. READFILE needs a comma between the file identifier and the variable: READFILE "Scores.txt", Score.
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 489–499) 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
READFILE "Scores.txt", ScoreFill in the Blanks
Spot the Error
Student with a class code? Join your class →