in reply to generate new files

Hi tkn, and welcome to Perl Monks :)

Firstly, it would be good if you could add <code> tags around your code. This will make it much easier to read. See Writeup Formatting Tips for more info on that.

Secondly, you could help us to help you if you provided a little more information. For example, what do $thecode and $rim1_thecode variables contain? (if anything). Is your code running with use strict and warnings enabled?

The most likely cause of your problem is that the $line variable is empty or undefined when you go to print it to the filehandle, but it's impossible to say for certain with the (lack of) information you've given.

Have a read of I know what I mean. Why don't you? and How (Not) To Ask A Question for some more tips on asking your question in such a way as to encourage good answers.

Cheers,
Darren :)