insert part of a filename in a textfile

Hi All,

I've got a textfile that i've stripped and edited using sed and want to insert part of the filename (original filename consists of: fw0204.txt.ncat_report.txt) but there are multiple files being delivered by an application to the data directory

The part of the filename that I need to insert is fw0204 with a whitespace at the end of it but I don't want to incorporate 'fw0204 ' in the script but instead use a general operator to do:

Work on fw0204.txt.ncat_report.txt and insert 'fw0204 ' in front of each line(without the quotes)
Work on fw0305.txt.ncat_report.txt and insert 'fw0305 ' in front of each line(without the quotes)
etc...

What I've done in the script with removing all kinds of things is:

# fill a container file with the available filenames
ls *.txt > filename_txt

# remove the first line of the textfile which contains a header
for x in `cat filename_txt`
do
sed '1d' $x > temp01_txt
cat temp01_txt > $x
done

#remove last 20 lines containing comments
for x in `cat filename_txt`
do
sed -e :a -e '$d;N;2,20ba' -e 'P;D' $x > temp02_txt
cat temp02_txt > $x
done

#remove trailing characters from each line (at the end)
for x in `cat filename_txt`
do
echo 'fw' | sed -e 's/fw.*//' $x > temp03_txt
cat temp03_txt > $x
done

Thanks in advance!