Added default file, added check for file type and fixed memory corruption