In an rc script you have root level access by default. What does "it
stops at the while loop" mean? It quits after a while, or so? I guess you
need to run your loop in the background in order to achieve functionality
usual in autostart scripts:
( while read -r line
#some stuff to do
done << (nc -l -p 4001) ) &
echo "Started with pid $( jobs -p )"