This study notes covers Deep Dive: Reading All Lines within File Handling for GCSE Computer Science. Revise File Handling in Programming for GCSE Computer Science with 15 exam-style questions and 10 flashcards. This topic appears regularly enough that it should still be part of a steady revision cycle. It is section 4 of 6 in this topic. Use this study notes to connect the idea to the wider topic before moving on to questions and flashcards.
Topic position
Section 4 of 6
Practice
15 questions
Recall
10 flashcards
Deep Dive: Reading All Lines
// Read all lines from a file
myFile = open("data.txt")
while NOT myFile.endOfFile()
line = myFile.readLine()
print(line)
endwhile
myFile.close()
Always close files! Leaving files open can cause data loss or corruption.