Plain text (TXT) files: structure
A plain text file holds unformatted characters, usually one line of text per line ended by a newline. It has no field headings or data types, so everything is read as a string.
Understanding Plain text (TXT) files: structure in VCE Software Development U3O1
What it does: Nothing in the file says that the lines are names and marks. The program must know the layout itself. int() converts the string read from the file into an integer. A TXT file stores no data types. Lines in a TXT file end with a newline character (\n). Closing tags belong to XML. line is a string, so line + 5 causes a type mismatch error. Convert it with int() first. A .txt file is plain text. XML files use tags to give the data structure. A TXT file usually stores one item of text per line, and each line is ended by a newline.
Common mistakes: Everything read from a text file is a string, so line + 5 mixes a string and an integer and causes a TypeError. Convert it first: total = int(line) + 5. readlines needs brackets to be called. Without them names holds the method itself, not the list of lines. It should be names = f.readlines().
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 98–113) and word search (Modules 72–113).
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
TXT fileFill in the Blanks
Spot the Error
Student with a class code? Join your class →