Which line of code is throwing this error? Could it be that indexing label is not working or the x = read(...)[0] call?
label
x = read(...)[0]