fix a bug with open (when closing first file and opening a new one)