title: Python remove line containing specific char at the front
body: <p>How do I remove a line from a txt file which start with &quot;&gt;&quot;?</p>
  <p>For example, in the txt file, there is about 250k+ lines and if I were to use the code below, it will take quite some time.</p>
  <pre><code>data = &quot;&quot;
  with open(fileName) as f:
       for line in f:
           if &quot;&gt;&quot; not in line:
               line = line.replace(&quot;\n&quot;, &quot;&quot;)
               data += line
  </code></pre>
  <p>An example of the txt file is:</p>
  <pre><code>&gt; version 1.0125 revision 0... # This is the line to be removed
  some random line 1
  some random line 2
  &gt; version 1.0126 revision 0... # This is the line to be removed
  ...
  </code></pre>
  <p>I have tried using <code>data = f.read()</code>, it is instant but the data will contain line that start with &quot;&gt;&quot;.</p>
  <p>Any help is appreciated. Thank you :)</p>