in reply to appending to a file

I think the problem in your script is your print line. You have:

print $in, "\n" ;#"$hu,$hd,$lt\n"
which I'm assuming you were originally trying to print what is in comments.

What you would really want is:

print $in "$hu,$hd,$lt\n"; # no comma between $in and "..."

Other important things: