Not a direct answer to OP's problem, but it may help you too. You can declare a local variable next to some html inside a scope without trouble.
@foreach (var item in Model.Stuff)
{
var file = item.MoreStuff.FirstOrDefault();
<li><a href="@item.Source">@file.Name</a></li>
}