// Open a new file for writing using FileManager (may have to remove an old one)
let fh: FileHandle = ... // open the file
// Header first (optional)
var s = "Pitch,Roll,Yaw\n" // note no spaces, comma is the operator
fh.writeData(s.data(using: .utf))
// then for each line of dat
s = String(format: "%f,%f,%f\n", trueData.attitude.pitch, trueData.attitude.roll, trueData.attitude.yaw)
fh.writeData(s.data(using: .utf))
// when done, close the file using fh.closefile()