pre-allocating the database

Also, using fprintf to create tab delimited spreadsheet instead of
writetable().