passed test on writing emails to file