Write logic for line end handler