Invalid write of newline in MakeTemporaryBundleFromTemplate

In some cases, this would cause an oob write if the string was empty. This patch uses StripTrailingNewline to remove the newline, which includes checks for empty strings.