Writing Error Logs into file