Strange behavior with input and output port

Please read the forum guide in the sticky post, then modify your post above and put in the code tags. As you can see, the forum has corrupted your code because you did not use code tags.