# Open the original file with open('original_file.txt', 'r') as original_file: # Read the first 100 lines lines = original_file.readlines()[:100] # Open or create a new file with open('new_file.txt', 'w') as new_file: # Write the first 100 lines into the new file new_file.writelines(lines)with open('myfile.txt') as f: first_line = f.readline()