Fixed NPE when output file is not provided.