title: How to loop through a txt file that is one line, and continuously linebreak on each tilde, until there are as many lines as there are tildes
body: <p>I have a large txt file, that is saved into one line. I can not show show due to privacy, but it would include some tildes throughout. </p>
  
  <p>As far as code is, here is the method that I have written currently to actually look in an entire directory, and then proceed to linebreak on each tilde. Right now, it linebreaks on the first tilde and then stops so that there is 2 lines. I deleted the filepath directory, because as stated before, there are privacy concerns. </p>
  
  <p>Thank you for all suggestions.</p>
  
  <pre><code>        public static void LineReturnTilde() //ReplaceAsterik
      {
          // where to start your directory walk
  
          var directoryToTraverse = @"\\";
  
          // what files to open
  
          var fileTypeToOpen = "*.820";
  
          // what to look for
          var patternToMatch = @"\~";
  
          var regExp = new Regex(patternToMatch);
  
          // the new content
  
          var patternToReplace = "~\r\n";
  
          // get all the files we want and loop through them to replace
  
          foreach (var file in Directory.GetFiles(directoryToTraverse, fileTypeToOpen, SearchOption.AllDirectories))
          {
              // open, replace, overwrite
  
                  var contents = File.ReadAllText(file);
  
                  var newContent = regExp.Replace(contents, patternToReplace);
  
                  File.WriteAllText(file, newContent);
  
          }
  
      }
  </code></pre>