added truncate fix. Left a test fail that reads past end of file, added code to make this failure happen as I think it is correct to fail here.