perl -pe 'chomp if s/^START//..s/^END//; s/\S\K$/ /' input.txt