(1) You are writing a C-Shell script and (2) You are invoking it with sh - a bourne-derived shell - to run with the -x option. (3) The sed invocation may be wrong as you will not see any output, changed or otherwise. Did you really mean the g for global substitute, or p for print the result of change?
While you could just rename passwd into passwd-old and then redirect the output of sed directly into a new passwd file this should help you back out if there are problems with the script.