'r' in file operations is used only for reading text files but for other files 'rb' should be used