Examo
PracticeAbout
Homecomputer-scienceFile Handling
0984

File Handling

Programming · 4 question types

Practise
Download PDF

0984 Topics

Programming Concepts13%
Arrays5%
File Handling3%
  1. Why Files Are Used
  2. CIE Pseudocode File-Handling Commands
  3. File Modes: READ, WRITE and APPEND
  4. Closing a File: Why CLOSEFILE Matters
  5. Reading a File Line by Line
  6. Writing to a File
  7. Storing a Book Record in a File
  8. File-handling Pitfalls
Procedures and Functions4%

Frequency legend

High (≥14%)
Above avg (10 to 13%)
Average (<10%)

Exam Frequency Analysis

Past paper frequency (2018 to 2024)

This topic accounts for approximately 3% of your exam marks.

stable
Rare
Stable3%

OPENFILE, READFILE, WRITEFILE, CLOSEFILE pseudocode operations appear occasionally.

A running program holds all its data in RAM, which is volatile: the moment the program ends or the computer is turned off, every variable disappears (topic 9). For data to survive across program runs, it must be saved to secondary storage as a file.

Files are how programs:

  • Remember user data between sessions (a saved game, a contact list, a logged-in session).
  • Read input data prepared elsewhere (a list of student names, a configuration file, a CSV export).
  • Write reports and logs that other programs or people can read later.
  • Share data between programs that do not run at the same time.

The CIE IGCSE syllabus focuses on text files: simple human-readable files made of lines of text.

The basic life cycle

Working with a file always follows the same four-step pattern:

  1. Open the file in the appropriate mode (read, write or append).
  2. Read lines from it or write lines into it.
  3. Continue until the work is done.
  4. Close the file.

Skipping the close step is one of the most common bugs in file-handling code. The next section explains why.

Previous

A 2D Array in Action: a TV-watching Log

Next

CIE Pseudocode File-Handling Commands