tsvfilename was defined inside if. Fixed.