undef $/; $file = <>; s/\s*\n/,/s; #catches spaces as well. print;