I use file append to add information to the txt file.
Code
file_append(LogDestination, LogHeader, 0)
file_append(LogDestination, LogData, 0)

And use the formatting to save the informations formatted to LogData String.
Code
strcat(LogData, strf(LogDataFormat, (string)Log_Asset,
(int)TradeID, 
(string)Log_TradeDirection, 
(int)Log_TradeTimeFrame, 
(var)TradeDate, 
(var)TradeExitDate, 
(int)TradeBars, 
(int)Lots, 
(var)TradePriceOpen, 
));