This is the error i get. Could someone help me fix and update this code. It also needs to be able to run from the command line.

```
Traceback (most recent call last):
  File "/Users/host-clc/Desktop/ping2.py", line 24, in <module>
    main()
  File "/Users/host-clc/Desktop/ping2.py", line 15, in main
    time = re.findall(r'time \w+',ping)[0]
IndexError: list index out of range

```

```
import subprocess, sys, re

filename = sys.argv[0]
f = open('pingfile.txt', 'r')
result = {}
# Header for IP and time

def main():
    print('IP, TimeToPing (ms)')
    # pings ip address
    for host in f.readlines():
        ping = subprocess.getoutput(f"ping -c 1 -t 2 {host}")
        dns = re.findall(r'\d+.\d+.\d+.\d+', ping)
        if 'time' in ping:
            time = re.findall(r'time \w+',ping)[0]
            time = time.replace('time ', '')
            # prints out results
            print(dns[0],', ', time)
        else:
            time = 'NotFound'
            print(dns[0],',', time)

if __name__ == "__main__":
    main()

```