Now input works and segfault is fixed. Thanks to rob for helping me :)