Added frist output file write