Logging cleanup #1

Rewrite remotepi.log each time a api.pl starts.
Check if LOG open before writing to it.