in reply to wanting to make a file of strings usable by SQL

I'd prefer to read the file in line by line, but I am wondering if that will let me acomplish what I want to do.

As previous posters showed, it is possible and comfortably even.

If you want to stick to your original approach, you could even use eof to to go from where you were stuck.
Though it's unnecessary complicated to stick too close to the sed-emulation.

As (I assume) such SQL argument lists are typically short (comparably), it shouldn't be a problem to handle the whole list in memory, as demonstrated by Skeeve.

Personally, I'm a map maniac, so my typical solution to this looks like:

print '(', join(',' => map {chomp; qq('$_')} <>), ')';

You also might want to meditate about what will happen, when your input data contains single quotes, eventually invalidating your SQL syntax