Log data from Arduino Serial to .txt file

I did ctrl+C and ctrl+V the code in the page but the indentations were lost, thanks for the tip