Escaping a line break

Escaping a line break

I'm currently struggling to escape a line break. I have a script that's outputting a string that I am writing to a file. This file is used by another program and it needs to see the line break to display what I want it to display. The issue is I can't seem to get a line break to escape properly to shop up in the next of the file instead of inserting a line break.

What I want is:
Sample Text\nSample second line

What I get is:
Sample Text
Sample second line

I've tried double escaping it, which just inserts the escape character.

Any ideas on how to accomplish this?