Works pretty much as `withTempFile`, except looks mapping up and uses temp. file only when necessary.