Raw Input Desired Output
Line 1
Line 2
Line 3

Line 4 Line 5

Line 6
Line 1
Line 2
----------
Line 3
----------
Line 4
Line 5
----------
Line 6
----------
Script and Comments
Script1
[ 1] /^$/{
[ 2] $!N
[ 3] /^\n$/!i\
[ 4] ----------
[ 5] D
[ 6] }
Comments
  1. Flow Chart:
  2. Pattern Space is abbreviated to 'PS'.
  3. If PS contains only one non-blank line, ^$ will not match, sed will jump to the end of script, print it, and start a new cycle.
  4. Otherwise, PS contains a blank line. Command 'N' of Step [2] will join next line.
  5. After 'N' is performed, if the current(recently joined) line is not a blank one, Command 'i' of Step [4] thru [5] will print a dashed line immediately.
  6. Command 'D' of Step [5] will delete the first line of PS and jump to Step [1].