Fixed file writing errors and same-day episode ordering