added code to create output file