added a check for whether a file to be imported is open