Updated line_completed function.