moved filewriter to a try statement within core to avoid matplotlib issues