title: Read from textfile, create number range, filter out float numbers outside the range and store the final values in text file
body: <p>I am having difficulty in creating a number range which will then filter the random float numbers stored in the text file and eventually store the numbers inside the number range. Let's say, for example, the number range to be 742.8 to 1000. I want to filter those outside this range and store the float numbers which are inside the range in the text file. </p>
  
  <p>I have created a text file which has random float numbers.
  I have successfully created a code that is able to read the numbers in text file.</p>
  
  <p>This is the random float numbers in the text file</p>
  
  <pre><code>743.6 
  742.8
  744.7
  743.2
  1000
  1768.6
  1750
  1767
  1780
  1500
  </code></pre>
  
  <p>This is my code(which is now able to read the above text file):</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.IO;
  
  namespace ReadTextFile
  {
      class Program
      {
          static void Main(string[] args)
          {          
              string filePath = "C:\\Users\\Student\\Desktop\\ConsoleApp1\\ConsoleApp1\\Data\\TextFile.txt";
  
              List&lt;string&gt; lines = File.ReadAllLines(filePath).ToList();
  
              foreach (string line in lines)
              {
                 Console.WriteLine(line);
              }
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p>Updated Version:
  Still could not remove the numbers from the range and store the numbers inside the range in text file.
  (When compiled the all the data from the text file is removed.)</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.IO;
  
  namespace ReadTextFile
  {
  class Program
  {
      static void Main(string[] args)
  
  
      {
  
          string usersPath = "C:\\Users\\Student\\Desktop\\ConsoleApp1\\ConsoleApp1\\Data\\TextFile.txt";
  
          List&lt;string&gt; lines = File.ReadAllLines(usersPath).ToList();
  
          StreamWriter writer = new StreamWriter(usersPath);
          foreach (string line in lines)
          {
              double x = double.Parse(line);
  
              if (x &gt; 740.9 &amp;&amp; x &lt; 1000.8)
              {
                  writer.WriteLine(line);
                //  Console.WriteLine(line);
  
              }
              writer.Close();
              Console.ReadLine();
          }
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The expected result: store whatever float numbers inside the number range in a text file.</p>