Błąd w skompilowanym programie 'access violation' [DELPHI]

Mój program kompiluje się w delphi ok lecz podczas działania wywala błąd access violation at address. Pokazuje się on tylko wtedy, gdy klikam ciągle wczytaj plik, a po wczytaniu usuń plik. Proszę o pomysły jak temu zapobiec. Korzystając z pewnego programu “EurekaLog” udało mi się wykryć, że błąd jest tu:

if OpenDialog1.Execute then

Screen blędu: http://img291.imageshack.us/img291/8982/bladk.pngA i błąd będzie widoczny tylko po skompilowaniu w delphi. Na dysku .exe tylko się zamknie. Gdyby ktoś chciał pobrać program: http://hotfile.com/dl/64887259/9787cf8/pr.rar.htmlKod wygląda następująco:

unit Unit1;


interface


uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, Buttons, Grids;


type

  TForm1 = class(TForm)

    OpenDialog1: TOpenDialog;

    StringGrid1: TStringGrid;

    BitBtn1: TBitBtn;

    procedure BitBtn1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;


var

  Form1: TForm1;


implementation


{$R *.dfm}


procedure TForm1.BitBtn1Click(Sender: TObject);

var

  Plik: TextFile;

  t : array of string;

  wiersz : integer;


begin

  if BitBtn1.Caption='Wczytaj plik' then

  begin

    if OpenDialog1.Execute then

      try

        begin

          wiersz := 0;

          AssignFile(Plik, OpenDialog1.FileName);

          Reset(Plik);

          while not Eof(Plik) do

          begin

            Inc(wiersz);


            if (wiersz > StringGrid1.RowCount-1) then

              StringGrid1.RowCount := StringGrid1.RowCount + 1;


            SetLength(t, wiersz+1);

            Readln(Plik, t[wiersz]);


            if (t[wiersz] = '') then

              Dec(wiersz)

            else

            begin

              StringGrid1.Cells[0, wiersz] := IntToStr(wiersz);

              StringGrid1.Cells[1, wiersz] := t[wiersz];

            end;

          end;

        end;

        CloseFile(Plik);


        BitBtn1.Caption := 'Usuń listę';

      except Application.MessageBox('Błąd przy wczytywaniu danych!', 'Wczytywanie danych', MB_OK + MB_ICONError);

      end;

  end

  else

  begin

    if Application.Messagebox('Czy chcesz usunąć listę?','Czyszenie danych' , MB_OKCancel)=IdOK then

    begin

      StringGrid1.RowCount := 2;

      StringGrid1.ColCount := 3;

      BitBtn1.Caption := 'Wczytaj plik';

    end;

  end;

end;


end.

nigdzie nie zmieniasz

StringGrid1.RowCount

a trzeba jak masz więcej niż jeden wiersz do wczytania.

a przecież w tej linii jest powiększany StringGrid:

if (wiersz > StringGrid1.RowCount-1) then

              StringGrid1.RowCount := StringGrid1.RowCount + 1;