Fixed: bug fix for resource leak while build document from file