Clean function to read all types of files