Deal output file closing behaviour

- close! if Tempfile
- close if regular File io