Changed pyb.accel() and pyb.time() to the new pyb.Accel() object and pyb.millis() function. Also shortened the loop so the writing is finished before the USB connection messes things up.