title: Download file in while loop C#
body: <p>I am trying to download a file to a directory on the users computer. I first remove all files I do not need, then I get the files to download from a file online which looks like this:</p>
  
  <p>FolderName|FileName|DownloadLink</p>
  
  <p>However it is only downloading the first file, and the loop is running forever.</p>
  
  <pre><code>class ModpackFileControl
  {
      static string modpackDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ImperialPVP");
      static string userDir = Properties.Settings.Default.userDir;
  
      public static void InstallUpdates()
      {
          //Delete Files
          ArrayList infoFiles = new ArrayList();
          infoFiles.Add("currentMods.txt");
          infoFiles.Add("previousMods.txt");
          infoFiles.Add("currentVersion.txt");
          infoFiles.Add("latestVersion.txt");
          infoFiles.Add("previousVersion.txt");
          infoFiles.Add("updateInfo.txt");          
  
          DirectoryInfo di = new DirectoryInfo(directory);
          foreach (FileInfo file in di.GetFiles())
          {
              if (!infoFiles.Contains(Convert.ToString(file)))
              {
                  file.Delete();
              }
  
          }
          foreach (DirectoryInfo dir in di.GetDirectories())
          {
              dir.Delete(true);
          }
  
          //Download Files
          string modpackFilesText = Path.Combine(modpackDir, "modpackFiles.txt");
  
          WebClient webClient = new WebClient();
          webClient.DownloadFile("https://dl.dropbox.com/s/lqqvg2fdw9qb989/modpackFiles.txt?dl=0", modpackFilesText);
  
          StreamReader modpackFiles = File.OpenText(modpackFilesText);
          string line = modpackFiles.ReadLine();
          while (line != null)
          {
              string[] files = line.Split('|');
  
              string folder = files[0];
              string file = files[1];
              if (!Directory.Exists(Path.Combine(modpackDir, folder)))
              {
                  Directory.CreateDirectory(Path.Combine(modpackDir, folder));
              }
  
              string downloadPath = Path.Combine(modpackDir, folder, file);
              string link = files[2];
              webClient.DownloadFile(link, downloadPath);
          }
  
          return;
      }
  }
  </code></pre>