/* Count the number of line breaks */
int line_breaks = 0;
- for (size_t i = 0; i < line.length() - 1; ++i) {
- if (line[i] == '\\' && (line[i+1] == 'n' || line[i+1] == 'N')) {
- ++line_breaks;
+ if (line.length() > 1) {
+ for (size_t i = 0; i < line.length() - 1; ++i) {
+ if (line[i] == '\\' && (line[i+1] == 'n' || line[i+1] == 'N')) {
+ ++line_breaks;
+ }
}
}