check for the case where buffer ends just a bit before the new line. Caused a segfault in the old program