Fixed loop else; made output histogram.