Added user error handling, fixed file input loop