That logic maybe sufficient on a basic level, but I feel in this exact situation, Utilitarianism is flawed in the sense that it does not take into account all of the facts and specifics. Here, the main objection to Utilitarianism involves it's own inclination to judge actions solely upon the greatest amount of utility. The greatest objection to Utilitarianism, in this case, is the fact that the trolley was originally on the track with the five people trapped on it. Assuming the driver is sane, and doesn't have issues with any of those who are trapped, the civilians are not connected to the driver in any moral sense. To be more specific, if the driver were to go into shock because of the horrible decision he had to make, or if the trolley's operation was run by machines and there was no driver at all, the trolley would run over the five civilians trapped on it's track. Taking the driver out of the original situation allows us to focus on the driver's actual decision. When it comes down to it, the driver is either choosing to let five civilians die (because, in reality, he did not make the choice for the trolley to be on that specific track), or to physically swerve the trolley and kill the lone civilian on the other track. This is where Utilitarianism has flaws in its theory. Letting something bad happen, and causing something bad to happen are two entirely different things; and Utilitarianism does not take that into account. How can it be morally permissible to consciously make a decision to kill someone who is not involved with your direct situation, when you are not to morally responsible for the other possibility? The answer: it can't be.
This new conclusion brings us to a slightly modified situation: the Doctrine of Double Effect. The Doctrine of Double Effect is another method in the philosophy of ethics to judge if actions are morally right or wrong. This doctrine finds the same problems with the Utilitarian's moral reasoning and offers a new solution for the Trolley Problem and similar situations.