fixed a typo
updated query writing to log, rather than stdout