Potentially, the problem is at line:
var firstTopicTag = topicTags.Value.Split(new char[] { '|' })[1];
You are expecting an array length of two post splitting and directly accessing the second value. Seems, post split, there is no value at that index and thus the error.
Please handle it.
Going forward, would strongly recommend to use Visual Studio debugger step-wise to see where from the error is raised - most of the times, you will be able to figure yourself on what could be going wrong.