import sys

filename = 'info.txt'
mode = 'w'  # write mode

# Step 1) Open the file
# Step 2) Verify successful file open 
try:
    infoFileObj = open( filename, mode )

    # Step 3) Read from or write to the file
    name = 'Dr. Carroll'
    infoFileObj.write( name + '\n')
    infoFileObj.write('I lived in Brazil for two years!\n')
except:
    print('ERROR! Unable to open or write to', filename)
    sys.exit()

# Step 4) Close the file
infoFileObj.close()