Use splitlines instead of split('\n') where appropriate