Added writing output to outputfile