Check if you have some kind of caching going on, I just tested your code and it adds the noindex right before the end of the head as expected.
Also just for the sake of sanity make sure you are testing this viewing a thread that actually has 0 replies.