Free GCSE Computer Science lessons for clear revision.

Free Lessons -> GCSE / Key Stage 4 -> Computer Science

GCSE Computer Science · Saved data

File handling and persistent data

Explain how programs read, write and append files so data persists after the program ends.

Programming45-60 minutesSelf-contained lesson

Lesson overview

Explain how programs read, write and append files so data persists after the program ends.

Focus: File handling and persistent data.

What you will learn

  • Define the key GCSE Computer Science terms used in file handling and persistent data.
  • Explain how open works in a practical scenario.
  • Compare read and write with an alternative or related method.
  • Apply file handling and persistent data accurately in exam-style questions.

Before you start

  • Variables and data types.
  • Lists and strings.
  • Robust programming.

File Handling scenarios

Use the high-score, attendance and settings examples below to choose suitable file operations.

File handling and persistent data infographic

GCSE Computer Science infographic showing how programs store and reload data with labels for Open | Read | Write | Close | CSV.
Use this visual to organise the key ideas for file handling and persistent data.Download visual

Explanation

Persistent data remains available after a program stops. Files are a common way for small programs to store data between runs.

Typical file operations include opening a file, reading data, writing or appending data and closing the file.

Programs should handle missing files, unexpected formats and permissions carefully so file errors do not crash the whole program.

Worked examples

Applying file handling

A quiz game needs to remember the best score.

The score should still exist next time the game starts.

The program reads the saved score on startup and writes a new score if it is higher.

Answer: Use a file to store the high score persistently, reading it at the start and writing the updated value when needed.

Quick checks

1. What does persistent data mean?

  1. a. Data shown only on a monitor
  2. b. Data that cannot be represented in binary
  3. c. Data kept after the program ends
Reveal answer

Answer: c. Correct. Persistent data survives beyond one run of the program.

Not quite. Focus on open in the scenario.

2. Which idea is most closely linked to file handling and persistent data?

  1. a. Close
  2. b. A monitor brightness setting
  3. c. A random file extension
Reveal answer

Answer: a. Correct. Close is part of this topic.

Not quite. Choose the option that belongs to the Computer Science concept.

Practice

1. Name one file operation.

Reveal answer

Answer: Open, read, write, append or close.

Marking: Credit valid operation.

2. Why close a file?

Reveal answer

Answer: To finish writing safely and release the resource.

Marking: Credit safe completion/resource release.

3. When might append be useful?

Reveal answer

Answer: Adding a new log entry without replacing existing content.

Marking: Credit adding to end.

4. Give one file-handling error to consider.

Reveal answer

Answer: Missing file, permission problem, invalid format or full storage.

Marking: Credit plausible file error.

Exam practice ladder

  • Fluency: recall the key term and use it accurately.
  • Application: apply the idea to the scenario rather than giving a generic definition.
  • Algorithmic reasoning: show the steps, condition or variable change clearly.
  • Evaluation: explain why one method, structure or control is suitable.

Answers and marking guidance

Exact answers and marking guidance are hidden under each question. For this lesson, earn marks by naming the correct Computer Science idea, applying it to the scenario and showing the logic or value change clearly.

Common mistakes

  • Assuming variables persist after a program closes.
  • Overwriting a file when append is needed.
  • Forgetting to validate data read from a file.
  • Ignoring missing-file errors.

Extension

Plan a simple attendance program that loads names from a file and saves present/absent results.

Next lesson

Next, continue with Searching and sorting algorithms.

Exam-board guidance

Aplailasain is an independent learning resource and is not endorsed by any exam board.

AQA GCSE Computer Science

AQA GCSE Computer Science: this skill supports problem solving, clear algorithms and accurate programming explanations.

OCR GCSE Computer Science

OCR GCSE Computer Science: expect precise algorithm reasoning, trace work and careful use of programming vocabulary.

Pearson Edexcel GCSE Computer Science

Pearson Edexcel GCSE Computer Science: practise explaining the method as well as giving the final answer or code.

Eduqas GCSE Computer Science

Eduqas GCSE Computer Science: secure the transferable idea first, then check how your class applies it in tasks.

WJEC Wales

WJEC Wales: use accurate terminology and show enough working for the examiner to follow your logic.

CCEA

CCEA: connect the idea to your class route and use the same algorithm, programming or systems vocabulary your teacher uses.