in reply to put a newline character after every four lines in a file
Why are you using `sed` inside Perl? Perl can handle regular expressions.