But file contains '?' in the filename
$filename contains a \n that you should chomp.
In reply to Re: Writing to a file by alexm in thread Writing to a file by Anonymous Monk