title: Bash script written in vim works differently than in the terminal! WHY?
body: <p>The idea is the bash script that enumerates internal ports (SSRF) of a website using ports in the &quot;common_ports.txt&quot; file and outputs the port and &quot;content-length&quot; of each port accordingly.</p>
  <p>That is curl request:</p>
  <pre class="lang-sh prettyprint-override"><code>$ curl -Is &quot;http://10.10.182.210:8000/attack?port=5000&quot;
   HTTP/1.0 200 OK 
   Content-Type: text/html; charset=utf-8
   Content-Length: 1035
   Server: Werkzeug/0.14.1 Python/3.6.9
   Date: Sat, 16 Oct 2021 13:02:27 GMT
  </code></pre>
  <p>To get the content length I have used grep:</p>
  <pre class="lang-sh prettyprint-override"><code>$ curl -Is &quot;http://10.10.182.210:8000/attack?port=5000&quot; | grep  &quot;Content-Length&quot;
    Content-Length: 1035
  </code></pre>
  <p>Till now everything was ok. But when I wrote it in vim to automate the process I got weird output.</p>
  <p>This is my full bash script:</p>
  <pre class="lang-sh prettyprint-override"><code>#!/bin/bash
  file=&quot;./common_ports.txt&quot;
  
  
  while IFS= read -r  line 
  do
          response=$(curl -Is &quot;http://10.10.182.210:8000/attack?port=$line&quot;)
           
          len=$(echo $response | grep  &quot;Content-Length:&quot;)
          echo &quot;$len&quot;
  done &lt; &quot;$file&quot;
  
  </code></pre>
  <p>An THIS IS THE OUTPUT:</p>
  <pre class="lang-sh prettyprint-override"><code>$ ./script.sh
   Date: Sat, 16 Oct 2021 13:10:35 GMT9-8
   Date: Sat, 16 Oct 2021 13:10:36 GMT9-8
  ^C
  </code></pre>
  <p>It outputs the last line of the <code>response</code> variable. Could anyone explain why??
  Thanks in advance!!!</p>