CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →

KwickClips Python · 45 sec · free

Why did my old lines vanish?

Short answer. You opened the file with mode w, which erases it first.

Which mode adds without erasing?

Mode a.

Six file modes

ModeDoesIf missing
rreadserror
werases, writescreates it
aadds at endcreates it
r+ w+ a+read + writelike r, w, a

Remember

w erases old text
a keeps it and adds

You opened a file to add a line, and old lines vanished. Why? You used the mode w. Mode r only reads. Mode w erases first. Mode a adds at the end. A plus adds reading and writing. Mode w erases old text. Mode a keeps it and adds.

This clip is from the full lesson: Text File Handling: Open, Read, Write and Append — 9 minutes, with the tables, the quick answers and the whole lesson in text.

Useful for: CBSE Class 12 Computer Science (083), CBSE Class 12 Computer Science (083), CBSE Class 12 Computer Science (083), Cambridge IGCSE Grade 9 Computer Science (0478)

More KwickClips from this lesson

Voice-over is AI-generated; the script is written and checked by Kajal Ma'am. Confirm anything you plan around against your official board document. We never ask for a password or an OTP.

Want a plan that actually fits your board dates?

Ask Kajal Ma'am directly, 20+ years teaching computer science. Free demo class first, no payment.

Talk to Kajal Ma'am on WhatsApp

Or see the Class 12 Computer Science course →

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →