With awk:
awk '{ORS=" ";}; !$0{ORS="\n"};1' file
The ORS variable specifies the output record separator. If the line if empty ($0 is not set) then the record separator should be a newline, else a space. The 1 at the end just means a positive condition, so awk prints the whole line.