added option to translate newlines to spaces, and added options parsing