Function to remove trailing lines.