It seems you just have wrongly thing assigned to newx. Instead of:
bank$rich <- NULL newx = data.matrix(test$rich)
I guess you need to null out the values in test$rich and then need to feed test to data.matrix. So something like below:
test$rich <- NULL newx = data.matrix(test) ridge.pred=predict(ridge.mod,newx=newx)
It worked for me.
Also i think your original data frame has some patterns based on the row: so rows after 200 have NA values in newAccount. So you may want to address missing values and your train/test split before your regression.