diff --git a/src/tools/chip-cert/GeneralUtils.cpp b/src/tools/chip-cert/GeneralUtils.cpp index bdcb9774fb006b..fce285d678acbf 100644 --- a/src/tools/chip-cert/GeneralUtils.cpp +++ b/src/tools/chip-cert/GeneralUtils.cpp @@ -340,8 +340,8 @@ bool WriteDataIntoFile(const char * fileName, const uint8_t * data, size_t dataL ExitNow(res = false); } - // Add new line if the output is stdout - if ((strcmp(fileName, "-") == 0) && (fwrite("\n", 1, 1, file) != 1)) + // Add new line if the output is to stdout in a text format + if ((strcmp(fileName, "-") == 0) && (dataFmt != kDataFormat_Raw) && (fwrite("\n", 1, 1, file) != 1)) { fprintf(stderr, "Unable to write to %s: %s\n", fileName, strerror(ferror(file) ? errno : ENOSPC)); ExitNow(res = false);