fix bug creating extra blank lines in resulting output