code now correctly identifies the filename and extension of the file