Changed writer to add newlines correctly. needs another fix