Wrap memprofiling in check that File was opened to write to.