fixing off SEEK_END according to andrew's suggestion