# L-28 MCS 260 Wed 16 Mar 2016 : readfilename2.py
"""
Prompts the user for a file name and displays
an error message if the name given by the user
does not correspond to a file.  Asks to retry.
"""
while True:
    NAME = input('Give the name of a file : ')
    try:
        INFILE = open(NAME, 'r')
        print('opened \"' + NAME + '\" for reading')
        INFILE.close()
        break
    except IOError:
        print('file \"' + NAME + '\" does not exist?')
        RETRY = input('Try again ? (y/n) ')
        if RETRY != 'y':
            break
