The reason it’s not outputing is because of the context of the razor syntax being executed. In your if block, all code runs as if you were in a regular C# context and the line:
Html.Raw("</tr><tr>");
Returns an MvcHtmlString but you are not doing anything with it. You need to enter an output context:
@Html.Raw("</tr><tr>");