Fixed bug in i/o and added script