fix bug where reader.Read() is only called once