Fixed problem with duplicate file opening