Added error checking with prints

Prints errors to stderr more accurately