writing to outputfile added