The line read in $linehas a final newlinechar. You must use chompto get rid of it. You have chomp in your code, but it is inappropriate. Move it to the beginning of the loop as:
while(my $line = <$fh>)
{
chomp($line);
$line=~s/^\s+//g;
print $str1.$line.$str2."\n";
}
EDIT:
Answer the question in the comment:
To remove leading spaces in a line:
$str =~s/^\s+//;
To remove a space ending (ending) in a line:
$str =~s/\s+$//;
To remove the leading and trailing spaces in a string:
$str =~s/^\s+|\s+$//g;