Automated NMAP. Help with script error

I have been writing a script using nmap. I have encountered an error that I have been unsuccessful in rectifying. My hope is that someone here can help with fixing this issue before I continue with its development.

The issue resides within the functions ‘scanprogress’ and ‘scanprogressVersion’. I receive an error ‘Segmentation Fault’ on the line of code where the function is created; lines 124 and 134 respectively. This occurs anytime I run the script where the while loop condition becomes false. At least that’s what it looks like to me. Here is a link to the github repository I made. It contains the script. Bless anyone who is willing to help me with this. The script has comments with brief explanations for certain functions. Please PM me with suggestions/advice. Thank you all.

https://github.com/Business1sg00d/AutomaticNMAP

Tips to Fix Script Errors
Turn Off Scripting Errors in IE.
Make Sure IE Isn’t Blocking Important Scripting Features.
Delete Temporary Internet Files.
Allow for Pop-ups in Your Browser.
Update Your Software.
Check Your Security Software.
Reset All of Internet Explorer’s Settings.
Disable Smooth Scrolling.

Regards,
Rachel Gomez