complete openFile() function

this function is used open a file and load the docment.