fixed the i/o and added a test file