How to write newline to sdfile?

Hi all,

i try to write sensor values to a line in a SD file, i use sdfatlib. It works OK.
But: i want to write a newline ("\n") every 5000 characters.

I thought of doing:

if (str.length() > 5000){
   sdfile.print("\n");
}

but it does not work very well. Which character should i use?

but it does not work very well. Which character should i use?

Ah, the famous "that didn't work" statement.

That code does something. You expect(ed) it to do something. What either thing is is not clear.

As a hint, though, the class you are using most likely derives from the Print class, this has both print() and println() methods. The println() methods do know how to place a carriage return AND line feed in the file.

Your call is adding one, but not the other, which, to some applications, makes a difference.

If say you were using Windows, and say Notepad to view the files, you would need to declare the Carriage Return character aswell as windows uses to move to a new line. You could try sdfile.print("\r\n").