Changed openFile to use a switch