now handles empty files better