added exceptions for better handling of EOL/EOF
EOL before EOF not needed anymore
don't print empty lines