Fixed bug when autodetecting read length