fix for only reopening file once