Overall, the old URL is removed (at least from the primary index) and the URL that is the target of the 301 redirect is indexed and receives most of the credit from the old URL (ie. PageRank, etc.). But the old URL will continue to be crawled at least as long as their are links somewhere pointing to it. Overall, you want to do whatever you can to have any such old links updated to point to the new URL - whether they're on your site or on external sites.
You code looks OK to me. You can always use one of the many online server header response checkers to see if your server is responding with a proper 301 redirect. Good luck!