import os os.chdir('/Users/jeanmarkgawron/python/intro/intro_lecture_files/') print os.getcwd() file_handle = open('hello.txt','r') l1 = file_handle.readline() # Method syntax! l2 = file_handle.readline() l3 = file_handle.readline() file_handle.close() l1_list = l1.split() file_handle2 = open('hello.txt','r') lines = file_handle2.readlines() # Read the entire file into a string. file_handle2.close() file_handle3 = open('hello.txt','w') for line in lines: line = line.strip() # remove carriage returns. print >> file_handle3, line[:-1] +'!' file_handle3.close()