Signed up recently but had issues with the confirmation email?

Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.

Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.

Revision notesQuestionsFor schools
Revise Computing
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Supplementary programming practice/File Handling Techniques

Writing files

301.15 File Handling Techniques

Practise exam questions

File Handling Techniques — Note 3 of 4

Append or overwrite content.

What you need to know

Use .write() to save text to a file. Remember to add \n for new lines — write() does not add them automatically. Use "w" to start fresh or "a" to add to existing content.

What to know

  • .write(text) saves text to the file
  • Does NOT auto-add newlines — use \n explicitly
  • "w" mode creates/overwrites; "a" mode appends
  • Write strings only — cast numbers with str() first

Code examples

Writing to a file
python
scores = [85, 92, 78]
with open("scores.txt", "w") as f:
    for s in scores:
        f.write(str(s) + "\n")
← Previous noteReading files301.15 File Handling TechniquesNext note →Closing files301.15 File Handling Techniques

Back to File Handling Techniques

Specification notes for programming are in Paper 2.

File Handling Techniques

Note 3 of 4

  1. 1Opening files
  2. 2Reading files
  3. 3Writing files
  4. 4Closing files
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Worried about something?Question Bank UpdatesPrivacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).