changed file_instance to 'wb' from 'rb'