Write Data to File

and format a little to include sample number