title: How do I solve I/O error 103 in delphi
body: <p>So Basically I'm in College in the UK (So that's school for Americans (17 years old)) and I have to make a file handling project for my finals.
  I have done most of it but it's the login screen that is weighing me down a lot. What I want from the program to do is read the username and password and log the people in. There can be 2 different outputs. If you type in "Staff" in the username and "warwickschool2013" in the username, the program takes you to the "teacher" side of the program where they can add in new users. </p>
  
  <pre><code>unit LoginScreen;
  interface
  
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, jpeg, ExtCtrls;
  
  type
    TfrmLogin = class(TForm)
      lblWelcomeLogin: TLabel;
      edtPassword: TEdit;
      lblPassword: TLabel;
      btnLogin: TButton;
      btnClose: TButton;
      lblCounter: TLabel;
      lblAttempts: TLabel;
      Image1: TImage;
      edtUsername: TEdit;
      lblUserName: TLabel;
      procedure btnCloseClick(Sender: TObject);
      procedure btnLoginClick(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    frmLogin: TfrmLogin;
  
  
  implementation
  uses MainMenu, TeachersMainMenu, ViewEditTheData, Globals_Unit;
  var
  LoginDataArray: array of TLoginData;
  counter: integer;
  Password, username : String;
  Count1, Count2 : integer;
  Temp: TLoginData;
  
  {$R *.dfm}
  
  procedure TfrmLogin.btnLoginClick(Sender: TObject);
  var
  SearchName : string[10];
  SearchCode : string[3];
  begin
    Password:=edtPassword.Text;
    UserName:=edtUserName.Text;
    btnclose.enabled:= true;
   if (Password = 'warwickschool2013') AND (Username = 'Staff') then
     begin
       edtPassword.text :='';
       frmTeachersMainMenu.show;
       frmLogin.hide;
       counter:= 0;
       lblCounter.caption := IntToStr(Counter);
    end
    else
     begin
       assignfile      (LoginDatafile,'C:\Users\NinjaBoffin\Desktop\Delphi\DataFiles\LoginData.txt');
       reset (LoginDatafile);
       LoginDatacounter := FileSize(LoginDatafile);
       SetLength(LoginDataArray, LoginDatacounter);
       edtPassword.clear;
       edtUserName.Clear;
       for Count1 := 1 to LoginDataCounter  do
         begin
            read(LoginDatafile,SingleLoginData);
            LoginDataArray[Count1] := SingleLoginData;
         end;
        closefile (LoginDatafile);
  
        //bubble sort
        edtUserName.Clear;
        for count1 := 1 to LoginDatacounter-1 do
           for count2 := 1 to LoginDatacounter-1 do
              if LoginDataArray[count2].UserName &gt; LoginDataArray[count2+1].UserName then
             begin
               temp := LoginDataArray[count2+1];
               LoginDataArray[count2+1] := LoginDataArray[count2];
               LoginDataArray[count2] := temp;
             end;
  //Linear Search (files getting ready)
  begin
    SearchName := edtUserName.text;
    assignfile     (LoginDatafile,'C:\Users\NinjaBoffin\Desktop\Delphi\DataFiles\LoginData.txt');
    reset (LoginDatafile);
    LoginDatacounter := FileSize(LoginDatafile);
    SetLength(LoginDataArray, LoginDatacounter);
    edtUserName.Clear;
    //Copying to array
    for  Count1 := 1 to StudentCounter do
     begin
        read(LoginDatafile,SingleLoginData);
        LoginDataArray[Count1] := SingleLoginData;
     end;
    closefile (Studentfile);
   //The actual linear search
  for  Count1 := 1 to StudentCounter do
   begin
     if LoginDataArray[Count1].Username = SearchName then
      begin
        assignfile    (LoginDatafile,'C:\Users\NinjaBoffin\Desktop\Delphi\DataFiles\LoginData.txt');
        reset (LoginDatafile);
        LoginDatacounter := FileSize(LoginDatafile);
        SetLength(LoginDataArray, LoginDatacounter);
        edtPassword.clear;
        for Count1 := 1 to LoginDataCounter  do
          begin
            read(LoginDatafile,SingleLoginData);
            LoginDataArray[Count1] := SingleLoginData;
          end;
          closefile (LoginDatafile);
          //bubble sort
         edtUserName.Clear;
         for count1 := 1 to LoginDatacounter-1 do
           for count2 := 1 to LoginDatacounter-1 do
               if LoginDataArray[count2].Password &gt; LoginDataArray[count2+1].Password then
                  begin
                    temp := LoginDataArray[count2+1];
                    LoginDataArray[count2+1] := LoginDataArray[count2];
                    LoginDataArray[count2] := temp;
                  end;
     //Linear Search (files getting ready)
     begin
        SearchName := edtPassword.text;
        assignfile (LoginDatafile,'C:\Users\NinjaBoffin\Desktop\Delphi\DataFiles\LoginData.txt');
        reset (LoginDatafile);
        LoginDatacounter := FileSize(LoginDatafile);
        SetLength(LoginDataArray, LoginDatacounter);
        edtPassword.clear;
        //Copying to array
        for  Count1 := 1 to StudentCounter do
         begin
          read(LoginDatafile,SingleLoginData);
          LoginDataArray[Count1] := SingleLoginData;
         end;
         closefile (Studentfile);
        //The actual linear search
         for  Count1 := 1 to StudentCounter do
           begin
             if LoginDataArray[Count1].Password = SearchName then
               begin
                 frmLogin.Hide;
                  frmMainmenu.Show;
               end;
            end;
          end;
     end;
    end;
   end;
   end;
  end;
  </code></pre>
  
  <p>If that is not the username and password you have to enter the password and username made by the teacher for you. This is in the teachers form and the file is "Logindata.txt". </p>
  
  <pre><code>procedure TfrmAddNewUser.btnAddNewStudentClick(Sender: TObject);
  begin
    assignfile (LoginDataFile,'C:\Users\NinjaBoffin\Desktop\Delphi\DataFiles\LoginData.txt');
    reset (loginDataFile);
    LoginDataCounter := FileSize(LoginDataFile);
    SingleLoginData.Username := edtNewUsername.text;
    SingleLoginData.Password := edtNewPassword.Text;
    //find where to store the record
    seek (LoginDataFile,LoginDataCounter);
    {...and put the record in}
    write(LoginDataFile,SingleLoginData);
    closefile (LoginDataFile);
    edtNewUserName.Text := '';
    edtNewPassword.Text := '';
  end;
  </code></pre>
  
  <p>I'm getting a constant I/O 103 error and I don't know where it's from (It's in the login form)
  So how do I fix this error? and will the login work?</p>
  
  <p>This is my first time programming</p>