Three changes: (1) change bitrate to 115200 to match avrdude, (2) use Array.shift instead of Array.pop (3) add debugging