added newlines where needed. Fixed program exit