I run all my BBS analyses on our Linux servers, so I’ve picked up some bash scripting tricks along the way. If you have a screen you want to kill (and there are multiple running), first find its name and then kill it.
screen -ls screen -X -S [session # you want to kill] kill
Also, while loops reading through files quit too soon if there’s not a newline character at the end of the last line. A fix…
while IFS='' read -r line || [[ -n "$line" ]]; do