Refactored rendering to make output file optional