This would be even better as `if output_file is not None`. It's just possible that someone could pass in a file-like object which behaves as False within a boolean context.