Added 'readPrefix' helper function