Make complete_line_internal (more?) exception safe