$Date2,$Difference | Out-File $To2\\Outputfile.txt -Append -width 200
Resulting my output in text files in 2 lines as below in, however i am expect
I think the problem is the ",". Use this "$Date2,$Difference" | Out-File $To2\Outputfile.txt -Append -width 200
In your example you are passing an array to the pipe with two elements $Date2,$Difference
which will make the statement on the right fire once for each element. Creating a single string will add the output together in the file.