Filter and write in to output file3