Single trailing newline.
Improved error handling.