If there is a space in your output file then it means there is a space in the HF value when it spans multiple lines.
The HF values in my test file were like so:
$
$ cat f2
example 1,
2.524075,-0.563322,-1.285286\H,0,-2.544438,-0.678834,1.199166\H,0,2.18
5962,-1.978001,0.018499\\Version=EM64T-G03RevE.01\State=5-A\HF=-1277.1
557592\S2=6.033269\S2-1=0.\S2A=6.000179\RMSD=8.037e-05\Thermal=0.\Dipo
le=-0.1643425,0.9094768,0.0321427\PG=C01 [X(C4H9Cr1O1)]\\@
example 2,
6256\H,0,-2.980236,0.00009,-0.45647\\Version=EM64T-G03RevE.01\State=5-
A\HF=-1198.5241253\S2=6.077753\S2-1=0.\S2A=6.000457\RMSD=4.977e-05\The
rmal=0.\Dipole=0.8534315,0.002042,-0.5745813\PG=C01 [X(C2H5Cr1O1)]\\@
$
$
$ # check HF values
$ perl -lne '/HF/ and print "==>|",$_,"|<=="' f2
==>|5962,-1.978001,0.018499\\Version=EM64T-G03RevE.01\State=5-A\HF=-1277.1|<==
==>|A\HF=-1198.5241253\S2=6.077753\S2-1=0.\S2A=6.000457\RMSD=4.977e-05\The|<==
$
$
And your input file probably has this:
$
$ perl -lne '/HF/ and print "==>|",$_,"|<=="' f2
==>|5962,-1.978001,0.018499\\Version=EM64T-G03RevE.01\State=5-A\HF=-1277.1 |<==
==>|A\HF=-1198.5241253\S2=6.077753\S2-1=0.\S2A=6.000457\RMSD=4.977e-05\The|<==
$
$
Notice how the Perl script, posted earlier, spews incorrect output for such a case:
$
$ perl -lne 'BEGIN {undef $/} while(/.*(HF=[^\\]+)\\.*/mg){$x=$1; $x=~s/\n//g; print $x}' f2
HF=-1277.1 557592
HF=-1198.5241253
$
That's because I am removing the newline but not the space. The following Perl script assumes that there could be one or more spaces in the HF value, and removes them.
$
$ # check HF value
$ perl -lne '/HF/ and print "==>|",$_,"|<=="' f2
==>|5962,-1.978001,0.018499\\Version=EM64T-G03RevE.01\State=5-A\HF=-1277.1 |<==
==>|A\HF=-1198.5241253\S2=6.077753\S2-1=0.\S2A=6.000457\RMSD=4.977e-05\The|<==
$
$ # modified Perl script
$ perl -lne 'BEGIN {undef $/} while(/.*(HF=[^\\]+)\\.*/mg){$x=$1; $x=~s/[\n ]//g; print $x}' f2
HF=-1277.1557592
HF=-1198.5241253
$
$
If you think there could be tabs as well, then add "\t" within those square brackets in the s/// operator. Or you could also add "\s" to take care of all whitespaces.
HTH,
tyler_durden