Improve output file type inference