modified openFile method