safely open file