Improved line matching in output