EEPROM programmer works with serial monitor but not with pySerial I'm trying to modify Ben Eater's eeprom programmer to flash a 32K eeprom, since the arduino has 32K of program data total the data wouldn't fit in the program. So I wrote a python program using pySerial to send the data in chunks of 256 bytes over serial. The arduino program works correctly when I manually send the data over the serial monitor, and the python program works correctly when I print the values to a console as a test, but when I actually run the program over serial it seems to only write zeros to the eeprom. Additionally, the Rx led on the arduino seems to be lighting up with the correct data, but like I said only zeros are written.
Here's the relevant arduino code:
void setup() {
  pinMode(SHIFT_DATA, OUTPUT);
  pinMode(SHIFT_CLK, OUTPUT);
  pinMode(SHIFT_LATCH, OUTPUT);
  digitalWrite(WRITE_EN, HIGH);
  pinMode(WRITE_EN, OUTPUT);
  
  Serial.begin(57600);
  dataArrPage = 0;
 
  //delay(1000);
  //Serial.println(&quot;Reading EEPROM&quot;);
  //printContents();

}

void loop() {
  if (Serial.available() &gt; 0) {
    int len = Serial.readBytes(dataArr, 256);

    for (int i = 0; i &lt; 256; i++) {
      writeEEPROM(dataArrPage + i, dataArr[i]); // writeEEPROM(address, data)
    }
    dataArrPage += 0x100;

    Serial.write('s'); //success, writing is done
  }
}

And the relevant python code:
import time
import serial
ser = serial.Serial('/dev/ttyUSB0', 57600)
time.sleep(4) # wait for arduino to initialize

filename = input(&quot;Enter file name: &quot;)
f = open(filename, &quot;rb&quot;)
data = f.read()

page = 0
for x in range(128): # 128 pages in 32K eeprom
    for i in range(256):
        #print(hex(data[(page * 256) + i])) # printing prints the correct values
        ser.write(data[(page * 256) + i])
    page += 1
    
    #wait until receive 's' from arduino
    while True:
        if ser.in_waiting &gt; 0:
            suc = ser.read(size=1)
            if suc == b's':
                print(&quot;Success&quot;)
                break

print(&quot;Writing done&quot;)
f.close()
ser.close()

I'm a beginner so sorry if it's something obvious.
I figured out the problem. The for loop was writing one byte at a time, which probably wasn't fast enough and caused a timeout in the arudino. The code is now:
page = 0
for x in range(128): # 128 pages in 32K eeprom
    datalst = []
    for i in range(256):
        datalst.append(data[(page * 256) + i])
        
    ser.write(datalst)

    #wait until receive 's' from arduino
    while True:
        if ser.in_waiting &gt; 0:
            suc = ser.read(size=1)
            if suc == b's':
                print(&quot;Success&quot;)
                break
            
    page += 1

I also changed the data types in the arduino sketch to use the ones in stdint.h which solved an unrelated bug. Let me know if I should post the full code for both.