Fixed error handling on huge files