forgot to update last line length to `nbuf' and fix memory error