The readlines() method reads all lines from a file and returns them as a list of strings, where each string is a line.
Basic syntax: python with open('file.txt', 'r') as f: lines = f.readlines() This opens a file and reads all lines into a list.
Once read, lines can be accessed using indexing: python print(lines[0]) # First line
You can loop through lines in the list: python for line in lines: print(line.strip()) This removes extra whitespace using .strip().
For large files, limit reading by iterating directly: python for line in f: print(line.strip())