Open tempfile before return