<?php

$text = "f
sdf
d
fdghg
w
ff
f
gggg
gg";

echo preg_replace("/^\S\n/m", "", $text);