Fix application does not raise error when open output file failed.

pull request test.