The easiest way to fix this substitution is to capture the extra characters:
s/([^\n])\n([^\n])/$1$2/g;
Although negative lookahead and/or lookbehind could be used instead:
s/(?<!\n)\n(?!\n)//g;
Lookahead and lookbehind assertions make sure that the subpattern matches (or doesn't match, for negative assertions), without using up those characters in the actual match.
perlre explains it better. :)