OSX Creating .sh scripts using appendText to copy files

I’m using the one liner tool to run a .sh script so I can copy files anywhere in OSX. I don’t know if my script generation code is wrong or my cp command is, as I always get the resulting copied file with an ? at the end. Here’s an example.

scriptFileOut.appendText("cp -a \"" + File::addTrailingSeparator(source.getFullPathName()) + ".\" \"" + File::addTrailingSeparator(target.getFullPathName()) + "\"\n");

And here’s an output script

I tried ending lines with \n and also \r\n and even \r, no difference. So it’s something that I don’t know about.

Thanks for any advice.

Cheers, WilliamK

This fixed the problem. :-/

void NewComponent::addStringToScriptFile(String input, bool newLine)
    	scriptFileOut.appendData(input.toUTF8(), input.getNumBytesAsUTF8());
    	if (newLine)
    		static String nL = "\n";
    		scriptFileOut.appendData(nL.toUTF8(), nL.getNumBytesAsUTF8());

Edit: Nevermind, using just \n instead of \r\n works…