fix bug where output could end with a hyphen