Can you download Sandeep's fixed script, then customize it by adding a trace to the shebang line?
curl -O -k https://www.uxlinux.com/upload/tmp/cwp_rc_fix.sh
nano cwp_rc_fix.sh
[b]#!/bin/bash -x[/b]
Then run it and watch it execute line-by-line:
sudo bash cwp_rc_fix.sh