A few issues:
the shape in the lxs file you attached has the wrong number of knots, however the code you pasted does not. However both miss one "P" point (44, should be nu*nv=5*9=45).
In addition there seems to be a bug in the nurbs code causing an out-of-bounds array access. However since I can't guess the missing "P" I won't be able to see if I have fixed it or not.
