A: 

You might want to check out PHP htmlentities and htmlspecialcharacters.

typoknig
A: 

Note: You are using jQuery.post() and setting your data as a $_GET parameters. It should be called like;

$.post("/php/getFile.php", { action: "write", file: file, newcfg: newcfg },
   function(data){
     alert("Data Loaded: " + data);
   });

You can keep your line breaks with a function like this:

function splitter($content) {
$content = str_replace(chr(10),'<br/>',$content);
$content = str_replace("<br/><br/><br/><br/>","<br/><br/>",$content);
return $content;
}

Which you run like:

$newcfg = splitter($newcfg);

And typoknig is right abouit special chars

Liam Bailey
The correct way to use post is exactly what I was looking for. I did not need the splitter function as I need to preserve \n instead of <br> as I am reading from and writing to unix configuration files (where a <br> wouldn't make sense). I also did not need htmlentities or htmlspecialcharacters for the same reason as above. Thank you!
Kyle
When you receive the answer that solves your problem, you should always accept it using the tick to the left of answer. A vote up never goes a miss either.
Liam Bailey
Thanks for the tip. I'm new here. I tried voting you up but I don't have enough reputation.
Kyle