title: If deleting not last item from StringList gives error
body: <p>I currently have an issue with the code</p>
  
  <pre><code>for i := 0 to stringlist1.count - 1 do
  begin
    found := false;
    for j := 0 to stringList2.count - 1 do
    begin
      if stringList1[i] = stringList2[j] then
      begin
        found := true;
        break;
      end;
    end;
    if not found then
    begin
      stringlist1.delete(i); 
    end;
  end;
  </code></pre>
  
  <p>If I have more than 1 item in the stringList1 and the item not found is first, or somewhere in the middle (not last) then I get an error: List index out of bounds(*)</p>
  
  <p>If for example I have 2 items in stringList1, and delete last (2nd) then no error. if I delete 1st (not last) then error: List index ouf of bounds(1) appears.</p>
  
  <p>I am not sure where to start to fix this.</p>