It would be simpler to just <code>
const int last_line_len = strlen(last_nl + 1);
</code>
In any case, you need the +1, or you're including the '\n' in your len.