added closeFile() to close buffer