Added function to increment variables

Added a function that increments the variables as if they were a binary
number.
Also, changed error to output to stderr instead of stdout, so error
messages show up if output is piped to a file.