changed a few file open/close precedures