libs/web: fix file handle leak in template parser