This code is slightly broken because it ignores a requirement that was specified by the problem (every section starts with a line containing a number which is the number of records) and relies on an assumption instead (every section is terminated by ==== followed by "\n"). There are at least three cases where this would break, and they do happen more often than not.
So, the wisdom behind this story: follow the specs carefully and don't golf when you don't need to.