Fix variables: length and end

Change from int to long int for large files.