aboyd,
Since your concern seems to be with speed, I would recommend taking a look at Performance Trap - Opening/Closing Files Inside a Loop. In a nutshell, the most cost effective approach is to avoid opening/closing filehandles and potentially to also buffer writes so that you reduce your biggest performance problem - IO.