added options for input, separated loop and chars building, added output sub