Remove encoding line which makes Python fail
Log from beginning to only next occurrence of end

User usually intends begin ... end to match begin with the first occurrence of
begin followed by some occurrence of end, and to match end with the *first*
occurrence of end after this occurrence of begin