Potentially more correct readstr implementation