Search⌘ K
AI Features

Reading and Printing a File

Explore how to handle plain text files in Python by reading and printing their contents. This lesson helps you understand file modes, opening and closing files, and prepares you to build a simple word counting tool based on a real Linux utility.

Linux built-in word count utility

We will begin by building a simple utility called word counter. If you’re familiar with Linux you’ll know this as the wc utility. On Linux, we can type:

wc <filename>

This ...