Aqui está um caminho possível
sed '/)\. $/ {
n
/^PORT/ i\
0 closed ports
}'
Teste
$ sed '/)\. $/ {
n
/^PORT/ i\
0 closed ports
}' < input
...
Nmap scan report for w.x.y.z (x.x.x.x)
Host is up (0.00090s latency).
0 closed ports
PORT STATE SERVICE
21/tcp open ftp
...
Nmap scan report for w.x.y.z (x.x.x.x)
Host is up (0.00079s latency).
Not shown: 2 closed ports
PORT STATE SERVICE
22/tcp open ssh
|_banner: SSH-2.0-mpSSH_0.2.1
...